我是android新手。我正在显示具有点击事件的列表视图。 当我点击任何一行时,它会转到ext活动。 我按下后退按钮时出现问题,列表视图不再可点击。 我在tab组下有这个逻辑。任何人都可以解释一下如何做到这一点吗?
public class MyCustomAdapter extends BaseAdapter {
String[] data_text;
int[] data_image;
int k;
MyCustomAdapter(String[] text, int[] image) {
data_text = data_text;
data_image = data_image;
}
MyCustomAdapter(ArrayList text, ArrayList image) {
data_text = new String[text.size()];
data_image = new int[image.size()];
for (int i = 0; i < text.size(); i++) {
System.out.println("In adapter2");
data_text[i] = text.get(i).toString();
data_image[i] = (Integer) image.get(i);
Log.e("",data_image[i]+"");
}
}
public int getCount()
{
return data_text.length;
}
public String getItem(int position)
{
return null;
}
public long getItemId(int position)
{
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater inflater = getLayoutInflater();
View row;
row = inflater.inflate(R.layout.list_item_review, parent, false);
TextView textview = (TextView) row.findViewById(R.id.TextView01);
ImageView imageview = (ImageView) row.findViewById(R.id.ImageView01);
textview.setText(data_text[position]);
imageview.setImageResource(data_image[position]);
return (row);
}
@Override
public void notifyDataSetChanged() {
// TODO Auto-generated method stub
super.notifyDataSetChanged();
}
}
这是onclick代码
listview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v1,int position, long id) {
Intent i = new Intent(ReviewTab.this, ReviewDetail.class);
View view = ReviewTabGroup.group.getLocalActivityManager().startActivity("com.MyITAssessment.ApplicationCodes.ReviewDetail",i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
ReviewTabGroup.group.replaceView(view);
}
});
答案 0 :(得分:1)
看到您的行视图冻结导致问题,请执行一项操作row xml
(R.layout.list_item_review)
并在行xml的main layout
中添加以下行代码。
机器人:descendantFocusability = “blocksDescendants”