Android 如何从自定义listview获取textview文本包含3个textview和一个imageview?
考虑到以下准则:Android 如何从自定义listview获取textview文本包含3个textview和一个imageview?,android,Android,考虑到以下准则: public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TextView textView = (TextView) listView.findViewById(R.id.namee); String title = textView.getText().toString(); TextView textVieww = (TextV
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TextView textView = (TextView) listView.findViewById(R.id.namee);
String title = textView.getText().toString();
TextView textVieww = (TextView) listView.findViewById(R.id.cityy);
String city = textVieww.getText().toString();
TextView textViewww = (TextView) listView.findViewById(R.id.placee);
String place = textViewww.getText().toString();
Toast.makeText(getActivity(),title+" "+city+" "+place,Toast.LENGTH_SHORT).show();
Data.title = title;
Data.city = city;
Data.place = place;
final FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.content_frame
, new ViewItemFrag()).commit();
}
如何获取listView中textView的访问文本?listView中的一行完整视图,用户单击该视图后,将作为名为view的参数传递给onItemClick函数。在检索文本时,只需使用view而不是listView,如下所示
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TextView textView = (TextView) view.findViewById(R.id.namee);
...
另外,请注意,这不是最佳做法-请选择本指南作为a的介绍。您的确切问题是什么?