現在作成のアプリにて、カスタムレイアウトでのListViewを使用しています。
ListViewへセットする、自作クラスを使ったArrayAdapterの継承クラス内の、TextViewにてonLongClickを呼んでいます。
そして、onLongClick内にてDialogFragmentを継承したクラスを表示する為に、
【hogeDialog.show】を呼びますが、その引数(FragmentManager,String)の第一引数のFragmentManagerの
取得をどのようにしたらよいのか、わかりません。
Activityなど継承したクラスではgetFragmentManager()ですが、この場合はどのような方法で取得可能でしょうか。
以下コードです。
どなたかご教示くださいませ。
public class PlanListAdapter extends ArrayAdapter<hoge>{
public PlanListAdapter(Context c, int id, ArrayList<User> users) {
super(c, id, users);
this.layoutInflater = (LayoutInflater) c.getSystemService(
Context.LAYOUT_INFLATER_SERVICE
);
}
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = layoutInflater.inflate( R.layout.plan_list_item, parent, false ); } User user = (User) getItem(position); ((TextView) convertView.findViewById(R.id.xxx)) .setText(user.getStr1()); ((TextView) convertView.findViewById(R.id.xxxx)) .setText(user.getStr2); final TextView tv1 = (TextView)convertView.findViewById(R.id.xxx); final TextView tv2 = (TextView)convertView.findViewById(R.id.task); ・ ・ ・ ・ tv1.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ・ ・ ・ Bundle bundle = new Bundle(); bundle.putString("xxx",xxx); bundle.putString("xxxx",xxxx); HogeDialog hogeDialog = new HogeDialog(); hogeDialog.setArguments(bundle); //ダイアログを表示
⇒⇒⇒ hogeDialog.show(どのような関数でFragmentManagerを取得?,"hoge");
return true; } }); return convertView; }
}
class
User{
private String str1; private String str2; public String getStr1(){ return str1; } public void setStr1(String str1){ this.str1 = str1; } public String getStr2(){ return str2; } public void setStr2(String str2){ this.str2 = str2; }
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。