我正在使用来自 Eclipse 的主详细信息流模板和一个自定义列表适配器,它显示一个图像和 3 段文本:
public class CustomAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String,String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;//I have a class for loading images
public CustomAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
data = d;
inflater = (LayoutInflater)activity.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
imageLoader = new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if(convertView == null)
vi = inflater.inflate(R.layout.list_row, null);
TextView text1 = (TextView) vi.findViewById(R.id.text1);
TextView text2 = (TextView) vi.findViewById(R.id.text2);
TextView text3 = (TextView) vi.findViewById(R.id.text3);
ImageView image= (ImageView) vi.findViewById(R.id.image);
HashMap<String, String> tap = new HashMap<String, String>();
tap = data.get(position);
// Setting all values in listview
text1.setText("item1");
text2.setText("item2");
text3.setText("item3");
imageLoader.DisplayImage(R.drawable.display_image,
R.drawable.loading_image, image);
return vi;
}
}
该方法setActiveOnItemClick()
在类中未更改,并且在双窗格模式下ItemListFragment
从类中调用此方法ItemListActivity
,与模板中完全相同。但是,在双窗格模式下单击时,列表项不会处于“激活”状态。为什么会这样,我该如何解决?