我通過參數將活動傳遞給對話框的IMageview。但是,當圖像出現在對話框的圖像視圖中時,它很模糊,質量也很差。 請參見下面的代碼:如何從公共/私人類訪問HashMap數據
在我的活動我的onclick監聽器:
mListView.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
//String item = ((TextView)view).getText().toString();
//int img = ((ImageView)view.findViewById(R.id.event_pic)).getId();
ImageView img = ((ImageView)view.findViewById(R.id.event_pic));
img.buildDrawingCache();
Bitmap bitmap = img.getDrawingCache();
String txt =((TextView)view.findViewById(R.id.subTitle_single)).getText().toString();
//Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
confirmEvent(txt, bitmap);
}
});
MY confirmEvent:
public void confirmEvent(CharSequence text, Bitmap id) {
DialogFragment mDialog = new MyDialogFragment();
Bundle args = new Bundle();
args.putCharSequence("text", text);
args.putParcelable("id", id);
mDialog.setArguments(args);
mDialog.show(getSupportFragmentManager(), "missiles");
}
我懷疑這是因爲當它到達的ImageView它已經被壓縮和格式化爲那個imageview。我知道我想要獲取圖像路徑而不是圖像視圖中的圖像,但我不確定正確的語法。由於圖像JSON從網站解析並存儲在harshMap:
我的HashMap(初步認識代碼):
/** AsyncTask to download and load an image in ListView */
private class ImageLoaderTask extends AsyncTask<HashMap<String, Object>, Void, HashMap<String, Object>>{
@Override
protected HashMap<String, Object> doInBackground(HashMap<String, Object>... hm) {
....
// Create a hashmap object to store image path and its position in the listview
HashMap<String, Object> hmBitmap = new HashMap<String, Object>();
// Storing the path to the temporary image file
hmBitmap.put("event_img",tmpFile.getPath());
// Storing the position of the image in the listview
hmBitmap.put("position",position);
// Returning the HashMap object containing the image path and position
return hmBitmap;
什麼是訪問該hmBitmap對象,這樣我可以用「正確的語法event_img「?
只是一個問題。您是否使用此任務來獲取要顯示的圖像? – Toguard
是的,但請記住,我沒有粘貼所有的代碼,只是相關的部分。 – crushman