我有listview的代码,当我点击列表中的每个项目时我需要获取项目的内容(IMAGE AND TEXT)然后我需要将它们发送到其他活动包含(tabhost)这个是我的代码:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int
position, long id) {
Intent intent = new Intent(Detail_Activity.this,
MoreDetailActivity.class);
LayoutInflater mInflater = getLayoutInflater();
View myView = mInflater.inflate(R.layout.detail_item, null);
TextView txtid = (TextView) view.findViewById(R.id.tv_name);
ImageView img = (ImageView) view.findViewById(R.id.img_id);
String stg = txtid.getText().toString();
}
});
答案 0 :(得分:1)
试试这个
String stg = view.getText().toString();
此代码段显示了如何从列表视图中获取图像视图
ImageView img = (ImageView) view.findViewById(R.id.img_id);
final BitmapDrawable bitmapDrawable = (BitmapDrawable) img.getDrawable();
final Bitmap yourBitmap = bitmapDrawable.getBitmap();
img.setImageBitmap(yourBitmap);
希望它有所帮助!