gridview.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Intent intent = new Intent(Index2Activity.this,Index_FocusCustomer.class);
LinearLayout tl_gv = (LinearLayout)arg1;
TableLayout table = (TableLayout)(tl_gv.getChildAt(0));
TableRow row = (TableRow)table.getChildAt(0);
TextView tv_cltcode = (TextView)row.getChildAt(0);
intent.putExtra("cltcode", tv_cltcode.getText().toString().trim());
Log.e("llllll",tv_cltcode.getText().toString());
startActivity(intent);
}});
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Intent intent = new Intent(Index2Activity.this,Index_FocusCustomer.class);
LinearLayout tl_gv = (LinearLayout)arg1;
TableLayout table = (TableLayout)(tl_gv.getChildAt(0));
TableRow row = (TableRow)table.getChildAt(0);
TextView tv_cltcode = (TextView)row.getChildAt(0);
intent.putExtra("cltcode", tv_cltcode.getText().toString().trim());
Log.e("llllll",tv_cltcode.getText().toString());
startActivity(intent);
}});
本文展示了一个使用Android GridView实现点击项并跳转到新Activity的示例代码。当用户点击GridView中的某一项时,应用会获取该项中的TextView内容,并将其作为参数传递给新的Activity。此过程展示了如何在Android中处理用户交互。
1229

被折叠的 条评论
为什么被折叠?



