Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use single variable to pass selected imageview value to another activity?
    primarykey
    data
    text
    <p>in my code below I pass txt1 txt2 txt3 name as parameters to another activity and get three time variables param1, param2, param3. Instead of these, <code>how do I use just a single variable which saves the value of press imageview?</code> <code>Can I get just a single variable which shows the press button value?</code>its work not but if i press breakfast is value iwllb bold but if i press supper or lunch textview not bold tell me why???</p> <pre><code> public class thirdstep extends Activity { ImageButton imgNews, imgContact, imgSetting; TextView txt1, txt2, txt3; private ImageLoader2 imgLoader; String MenuSelect; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.category_list2); ImageView img1 = (ImageView) findViewById(R.id.img1); txt1 = (TextView) findViewById(R.id.txt1); ImageView img2 = (ImageView) findViewById(R.id.img2); txt2 = (TextView) findViewById(R.id.txt2); ImageView img3 = (ImageView) findViewById(R.id.img3); txt3 = (TextView) findViewById(R.id.txt3); MenuSelect = Utils.MenuSelect; imgLoader = new ImageLoader2(this); try { HttpClient client = new DefaultHttpClient(); HttpConnectionParams .setConnectionTimeout(client.getParams(), 15000); HttpConnectionParams.setSoTimeout(client.getParams(), 15000); HttpUriRequest request = new HttpGet(MenuSelect); HttpResponse response = client.execute(request); InputStream atomInputStream = response.getEntity().getContent(); BufferedReader in = new BufferedReader(new InputStreamReader( atomInputStream)); String line; String str = ""; while ((line = in.readLine()) != null) { str += line; } JSONObject json = new JSONObject(str); JSONArray data = json.getJSONArray("worldpopulation"); JSONObject jsonOrder = (JSONObject) data.get(0); txt1.setText(jsonOrder.getString("name")); String url1 = jsonOrder.getString("url"); imgLoader.DisplayImage(url1, img1); JSONObject jsonOrder2 = (JSONObject) data.get(1); txt2.setText(jsonOrder2.getString("name2")); String url2 = jsonOrder2.getString("url2"); imgLoader.DisplayImage(url2, img2); JSONObject jsonOrder3 = (JSONObject) data.get(2); txt3.setText(jsonOrder3.getString("name3")); String url3 = jsonOrder3.getString("url3"); imgLoader.DisplayImage(url3, img3); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } img1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent iMenuList = new Intent(thirdstep.this, fourthscreen.class); iMenuList.putExtra("Menuitem", txt1.getText().toString()); startActivity(iMenuList); } }); img2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent iMenuList = new Intent(thirdstep.this, fourthscreen.class); iMenuList.putExtra("Menuitem", txt2.getText().toString()); startActivity(iMenuList); } }); img3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent iMenuList = new Intent(thirdstep.this, fourthscreen.class); iMenuList.putExtra("Menuitem", txt3.getText().toString()); startActivity(iMenuList); } }); } } public class fourthscreen extends Activity Bundle bundle = this.getIntent().getExtras(); String param1 = bundle.getString("Breakfast"); String param2 = bundle.getString("Lunch"); String param3 = bundle.getString("Supper"); </code></pre> <p><code>Is it possible i just used single variable?</code> </p> <pre><code> String param1 = bundle.getString("Presimageview value???"); if(param1.equalsIgnoreCase("BreakFast")) { Breakfast.setTypeface(null, Typeface.BOLD); } else if(param1.equalsIgnoreCase("Lunch")) { Lunch.setTypeface(null, Typeface.BOLD); } else if(param1.equalsIgnoreCase("Supper")) { Lunch.setTypeface(null, Typeface.BOLD); } i did using this code iMenuList.putExtra("Menuitem", txt3.getText().toString()); iswork now //textview value not bold on lunch and supper only brekafast value wll bold </code></pre>
    singulars
    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