Note that there are some explanatory texts on larger screens.

plurals
  1. POsetting image from grid view in dialog to another grid view in the main layout
    primarykey
    data
    text
    <p>In my main layout i have a grid view with some images from resource folder. when i click an image on the main grid view a dialog window pop ups and shows another grid view contains images from sdcard. When i click an image on the grid view on dialog i want to set the clicked image on to the position that is clicked on the main grid view. </p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); image.add(R.drawable.split1); image.add(R.drawable.spli21); image.add(R.drawable.split22); image.add(R.drawable.split31); image.add(R.drawable.split32); image.add(R.drawable.split33); image.add(R.drawable.split34); image.add(R.drawable.split41); image.add(R.drawable.split42); image.add(R.drawable.split43); gv = (GridView) findViewById(R.id.gridView1); gv.setAdapter(new AppsAdapter(MainActivity.this,image)); gv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,long id) { // TODO Auto-generated method stub // Toast.makeText(getBaseContext(), // "pic" + (position) + " selected", // Toast.LENGTH_SHORT).show(); //Context context = getApplicationContext(); if(position==0) { createdialog(position); } } }); } public void createdialog(int pos8) { pos1 = pos8; System.out.println("Position-&gt;"+pos1); dialog = new Dialog(this); dialog.setContentView(R.layout.content); dialog.setTitle("Select Contents !!"); dirs.clear(); listFilesSDcard = new File(Environment.getExternalStorageDirectory() .toString()); System.out.println("listFilesSDCard-&gt;"+listFilesSDcard); getFolderList(listFilesSDcard, dirs); System.out.println("ArrayList dirs Contains-&gt;"+dirs); sgv = (GridView) dialog.findViewById(R.id.gridView); sgv.setAdapter(new AppsAdapter1(dirs,pos1)); dialog.show(); } /* Apps adapter for dialog gridview */ public class AppsAdapter1 extends BaseAdapter { ArrayList&lt;File&gt; dirsTemp1 = new ArrayList&lt;File&gt;(); //int pos5; /*Arraylist dirs contains the sdcard image files*/ public AppsAdapter1(ArrayList&lt;File&gt;dirs,int pos10) { Log.d("In appsadapter2","Hiii"); dirsTemp1 = dirs; pos2 = pos10; } //---returns the number of images--- public final int getCount() { return dirsTemp1.size(); } //---returns the ID of an item--- public final Object getItem(int position) { return dirsTemp1.get(position); } public final long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub //int i=1; View v = null; Bitmap mOriginalBitmap = null; //View view; //Bitmap map1; final File f = (File) getItem(position); if (convertView == null) { LayoutInflater li = getLayoutInflater(); v = li.inflate(R.layout.gridicon, null); ImageView iv = (ImageView) v.findViewById(R.id.imageView); TextView tv = (TextView) v.findViewById(R.id.texttag); tv.setTextColor(Color.BLACK); String fName = f.getName(); if (f.isFile()) { if (fName.endsWith(".png") || fName.endsWith(".jpeg") || fName.endsWith(".jpg") || fName.endsWith(".bmp")) { tv.setText(fName); mOriginalBitmap =BitmapFactory.decodeFile(f.getAbsolutePath()); } if (mOriginalBitmap != null) { mOriginalBitmap = Bitmap.createScaledBitmap(mOriginalBitmap, 75, 75, true); iv.setImageBitmap(mOriginalBitmap); } } } else { v = convertView; } v.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { // TODO Auto-generated method stub // ***** I stuck here ****/ if (dialog != null) dialog.dismiss(); String path = f.getAbsolutePath(); Toast.makeText(getBaseContext(),"long clicked",Toast.LENGTH_LONG).show(); Bitmap pass = BitmapFactory.decodeFile(path); return false; } }); return v; } } </code></pre> <p>I just read images from sd card and shows it on a grid view in dialog. How did i replace the image on main grid view with the long clicked image on dialog grid view ? I got stuck with the onlong click listener of the dialog grid view .. Plz help me. thanks in advance..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload