我是android新手。我正在顯示具有點擊事件的列表視圖。 當我點擊任何行時,它會進入分機活動。 我有問題,當我按回列表視圖不能點擊任何更多。 我在選項卡組下有這個邏輯。任何人都可以解釋如何做到這一點?列表視圖不可點擊
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);
}
});
你編寫背面按什麼嗎?併發布你的listview點擊事件。 – RobinHood
請確保您的列表視圖一樣,listview..setOnItemClickListener(新OnItemClickListener(){ \t \t \t @覆蓋 \t \t \t公共無效onItemClick(適配器視圖>爲arg0,ARG1查看,INT ARG2, \t \t \t \t \t長ARG3 ){ \t \t \t \t // TODO自動生成方法存根 \t \t \t \t //在這裏,我你的代碼。 \t \t \t} \t \t}); –
@Hiren Dabhi請檢查更新的代碼 –