我正在尝试获取图像并希望将其放入HashMap
使用 `Button.onClickListener()
我确定我在这里做错了:
String s_image = imgv.toString();
我想在这里我应该使用 ImageView 代替 String,但是怀疑如何以及需要编写什么代码
Logcat 说:
05-11 10:56:51.760: D/dalvikvm(299): GC_EXTERNAL_ALLOC freed 2253 objects / 144464 bytes in 48ms
05-11 10:57:16.500: D/Single(299): ImageURL :: http://2.imimg.com/data2/EE/RJ/MY-932393/children-suits-250x250.jpg
05-11 10:57:17.920: D/Single(299): Title :: Kids
05-11 10:57:17.920: D/Single(299): Image :: android.widget.ImageView@46092008
Single.java 代码:
public class Single extends Activity {
public static final String LOG_TAG = "Single";
public static final String TAG_TITLE = "title";
public static final String TAG_IMAGE = "image";
String s_title, s_image;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.information_product);
Intent in = getIntent();
String title = in.getStringExtra(TAG_TITLE);
String image = in.getStringExtra(TAG_IMAGE);
Log.d(Single.LOG_TAG, "ImageURL :: " + image);
final ImageLoader imageLoader = new ImageLoader(getApplicationContext());
final ImageView imgv = (ImageView) findViewById(R.id.single_thumb);
final TextView txttitle = (TextView) findViewById(R.id.single_title);
txttitle.setText(title);
imageLoader.DisplayImage(image, imgv);
Button mImgAddCart = (Button) findViewById(R.id.button_add);
mImgAddCart.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
s_title = txttitle.getText().toString();
Log.d(Single.LOG_TAG, "Title :: " + s_title);
s_image = imgv.toString();
Log.d(Single.LOG_TAG, "Image :: " + s_image);
if (Session.item_data.size() <= 0) {
HashMap<String, String> h_obj = new HashMap<String, String>();
h_obj.put(TAG_TITLE, s_title);
h_obj.put(TAG_IMAGE, s_image);
Session.item_data.add(h_obj);
}
}
});