リスト項目がクリックされたときにカスタム ダイアログを開きたい。コードに実装するにはどうすればよいですかonClickListener
:
public class Fragment4 extends Fragment{
private View parentLayout;
private ListView listView;
private ArrayList<String> myList;
private AboutUsAdapter adapter; //custom adapter
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
parentLayout = inflater.inflate(R.layout.fragment_4, null);
listView = (ListView)parentLayout.findViewById(R.id.listView4);
myList = new ArrayList<String>();
myList.add("Item1");
myList.add("Item2");
myList.add("Item2");
adapter = new AboutUsAdapter(getActivity().getBaseContext(), myList);
listView.setAdapter(adapter);
return parentLayout;
}
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
}
}); } }