Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to print value from out of main method toinside main method
    primarykey
    data
    text
    <p>how to access value which is out of main class? i want to print value of elementarytxtview in main class in parameter but is print null value of in parameter i want to pass elementarytextview value in parameter to other activity</p> <pre><code> public class HomeMenu extends Activity { ImageButton imgNews, imgContact, imgSetting; ListView listMainMenu; ListView Middleschoollist, HighSchoollist, Atipicalschoollist; String status; firstscreenadapter mma; String SelectMenuAPI; String SelectMenuAPI2; String url1; String elementry; // String High; String message; TextView Elementarytxt, Middletxt, Hightxt, Atypicaltxt; static ArrayList&lt;Long&gt; Category_ID = new ArrayList&lt;Long&gt;(); static ArrayList&lt;String&gt; Category_name = new ArrayList&lt;String&gt;(); String elementarytxtview; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.firstscreenfinal); ExpandableHeightListView listMainMenu = (ExpandableHeightListView) findViewById(R.id.listMainMenu11); ExpandableHeightListView Middleschoollist = (ExpandableHeightListView) findViewById(R.id.listMainMenu22); ExpandableHeightListView HighSchoollist = (ExpandableHeightListView) findViewById(R.id.listMainMenu33); ExpandableHeightListView Atipicalschoollist = (ExpandableHeightListView) findViewById(R.id.listMainMenu44); Elementarytxt = (TextView) findViewById(R.id.Elementaryschool); Middletxt = (TextView) findViewById(R.id.MiddleSchool); Hightxt = (TextView) findViewById(R.id.HighSchool); Atypicaltxt = (TextView) findViewById(R.id.AtipicalSchool); mma = new firstscreenadapter(this); if (!Utils.isNetworkAvailable(HomeMenu.this)) { Toast.makeText(HomeMenu.this, "NO NETWORK Available", Toast.LENGTH_SHORT).show(); } if (!Utils.isUserOnline(this)) { Toast.makeText(this, "No NETWORK", Toast.LENGTH_LONG).show(); } url1 = "http://198.57.208.46/~school/ajax.php?action=get_school"; listMainMenu.setAdapter(mma); Middleschoollist.setAdapter(mma); HighSchoollist.setAdapter(mma); Atipicalschoollist.setAdapter(mma); listMainMenu.setExpanded(true); Middleschoollist.setExpanded(true); HighSchoollist.setExpanded(true); Atipicalschoollist.setExpanded(true); Toast.makeText(this, elementarytxtview, Toast.LENGTH_SHORT).show(); listMainMenu.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub Intent iMenuList = new Intent(HomeMenu.this, SecondStep.class); iMenuList.putExtra("category_name",xxx.xxx.xxxx/~school/index.php /api/index/getschools?mg="+ Category_name.get(position)+ "&amp;sl="+elementarytxtview); startActivity(iMenuList); } }); parseJSONData(); } void clearData() { Category_ID.clear(); Category_name.clear(); } public void parseJSONData() { SelectMenuAPI = Utils.Homemenu2; SelectMenuAPI2 = Utils.Homemenu; clearData(); try { HttpClient client = new DefaultHttpClient(); HttpConnectionParams .setConnectionTimeout(client.getParams(), 15000); HttpConnectionParams.setSoTimeout(client.getParams(), 15000); HttpUriRequest request = new HttpGet(SelectMenuAPI); 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; } HttpClient client2 = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client2.getParams(), 15000); HttpConnectionParams.setSoTimeout(client2.getParams(), 15000); HttpUriRequest request2 = new HttpGet(SelectMenuAPI2); HttpResponse response2 = client2.execute(request2); InputStream atomInputStream2 = response2.getEntity().getContent(); BufferedReader in2 = new BufferedReader(new InputStreamReader( atomInputStream2)); String line2; String str2 = ""; while ((line2 = in2.readLine()) != null) { str2 += line2; } JSONObject json3 = new JSONObject(str2); // message = json2.getString("message"); status = json3.getString("status"); if (status.equals("1")) { JSONArray school2 = json3.getJSONArray("data"); String[] mVal = new String[school2.length()]; for (int i = 0; i &lt; school2.length(); i++) { mVal[i] = school2.getJSONObject(i).getString("title"); Elementarytxt.setText(mVal[0]); Middletxt.setText(mVal[1]); Hightxt.setText(mVal[2]); Atypicaltxt.setText(mVal[3]); } elementarytxtview = mVal[0]; } JSONObject json2 = new JSONObject(str); // message = json2.getString("message"); status = json2.getString("status"); if (status.equals("1")) { // JSONObject data = json.getJSONObject("data"); JSONArray school = json2.getJSONArray("data"); for (int i = 0; i &lt; school.length(); i++) { JSONObject object = school.getJSONObject(i); // Category_ID.add(Long.parseLong(object.getString("id"))); Category_ID.add((long) i); Category_name.add(object.getString("title")); } } else { Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block // IOConnect = 1; e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    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