[英]I need when I click in every item in the list I want to get the content of item (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();
}
});
尝试这个
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);
希望能帮助到你 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.