Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamic button click android
    primarykey
    data
    text
    <p>I want to change the image of the button when clicked on particuar button and deselet all the other one please help.</p> <p>This is my code</p> <pre><code>public void onClick(View view) { Object tag = ((Button) view).getTag(); System.out.println("value o ftagagdsgsdg:::" +tag.toString()); String strtag = tag.toString(); System.out.println("value of strtag:::" +strtag); enablebutton = Integer.valueOf(tag.toString()); System.out.println("value of enable buttons variable::" +enablebutton); DeselectButtons(); ((Button)view).setEnabled(true); for(int a = 0;a&lt;adapt_obj.city_id_array.length;a++){ System.out.println("ddsgdgsdg::"+adapt_obj.city_code_array[a]); System.out.println("value o ftagagdsgsdg:inside for loop::" +tag.toString()); if(tag.toString() == adapt_obj.city_code_array[a]){ ((Button)view).setFocusable(true); //clicked = false; // Calling process to fetch the data of city selectedcityidclicked(tag.toString(), view); ((Button)view).setSelected(true); /*Drawable dr = getResources().getDrawable(R.drawable.location_btn_active_1);// active Bitmap bitmap = ((BitmapDrawable) dr).getBitmap(); // Scale it to 50 x 50 // Set your new, scaled drawable "d" ((Button)view).setBackgroundDrawable(new BitmapDrawable(Bitmap.createScaledBitmap(bitmap, 10, 10, true)));*/ // ((Button)view).invalidate(); } else if(tag.toString() != adapt_obj.city_code_array[a]){ /*((Button)view).setFocusable(true); selectedcityidclicked(tag.toString(), view); Drawable dr2 = getResources().getDrawable(R.drawable.location_btn_active_1);// inactive Bitmap bitmap2 = ((BitmapDrawable) dr2).getBitmap(); // Scale it to 50 x 50 Drawable d2 = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap2, 10, 10, true)); // Set your new, scaled drawable "d" ((Button)view).setBackgroundDrawable(d2); ((Button)view).invalidate(); clicked = false;*/ } } /*else if(tag.toString() != adapt_obj.city_code_array[a]){ ((Button)view).setFocusable(true); Drawable dr2 = getResources().getDrawable(R.drawable.location_btn_inactive_1);//instead of inactive Bitmap bitmap2 = ((BitmapDrawable) dr2).getBitmap(); // Scale it to 50 x 50 Drawable d2 = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap2, 10, 10, true)); // Set your new, scaled drawable "d" ((Button)view).setBackgroundDrawable(d2); ((Button)view).invalidate(); } else { Drawable dr2 = getResources().getDrawable(R.drawable.location_btn_active_1);//white Bitmap bitmap2 = ((BitmapDrawable) dr2).getBitmap(); // Scale it to 50 x 50 Drawable d2 = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap2, 10, 10, true)); // Set your new, scaled drawable "d" ((Button)view).setBackgroundDrawable(d2); ((Button)view).invalidate(); }*/ /*((Button) view).setText("*"); //selectedcityidclicked(tag.toString()); ((Button) view).setEnabled(false);*/ } private void DeselectButtons() { // TODO Auto-generated method stub for(int x=0; x&lt;adapt_obj.city_code_array.length;x++){ System.out.println("value of enable tag::" +enablebutton); System.out.println("valuie dofdsf xxx:::" +x); if (enablebutton!= x) //What should i do here as i had to take the un clicked button as set selected as false // // ((Button)view).setSelected(false); //this.findViewById(i).setSelected(false); //this.findViewById(i).setSelected(false); } } private void selectedcityidclicked(String cityval, View view) { cityidvalue = "&amp;city_code="+cityval; System.out.println("value of cityidvalue::" +cityidvalue); new MyAsyncTask(view).execute(); } </code></pre>
    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.
 

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