Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add rows dynamically into table layout from JSONARRAY Data?
    text
    copied!<p>i want to add row dynamically to my tableview like iphone with two TextViews and one EditText for Editing data to webservices also i want Scrolling tableview . ineed som sample code so i can proceed or if any have any alternet solution plz suggest me .</p> <p>I have this Json and want to bind json data with each row in tableview </p> <pre><code>try { json = new JSONObject(status); getArray_Meter_Reading = new JSONArray(); getArray_Meter_Reading = json.getJSONArray("meterReadings"); if (getArray_Meter_Reading.length() == 0) { AlertDialog.Builder builder = new AlertDialog.Builder( NewTransaction.this); builder.setTitle("WARNING"); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setMessage("No Meters Found"); builder.setPositiveButton("ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); AlertDialog diag = builder.create(); diag.show(); } } catch (JSONException e) { e.printStackTrace(); } </code></pre> <p>Plz help to achive this im new to android so i need help Can any buddy have solution for this . Thanks in advance </p> <pre><code>public View getView(final int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); EditText ed_Current = (EditText) view.findViewById(R.id.ed_Current); ed_Current.setTag(position); ed_Current.setOnFocusChangeListener(new View.OnFocusChangeListener() { public void onFocusChange(View arg0, boolean arg1) { if (v == null) { v = arg0; int tag = (Integer) arg0.getTag(); Caption = (EditText) arg0; previous_Meter_Reading = new HashMap&lt;String, String&gt;(); previous_Meter_Reading = c.get(tag); String getPreviousReading = previous_Meter_Reading .get("previousMeterReading"); String CumulativeIndex = previous_Meter_Reading .get("Cumulative"); previousMeterReading = Integer.parseInt(getPreviousReading); Cumulative = Integer.parseInt(CumulativeIndex); } Toast.makeText(context, "getPrevious" + previousMeterReading, Toast.LENGTH_SHORT); Toast.makeText(context, "Cumulative" + Cumulative, Toast.LENGTH_SHORT); Log.i("Hello", "getPrevious" + previousMeterReading); Log.i("Hello1", "Cumulative" + Cumulative); if (v != arg0) { if (!Caption.getText().toString().equals("") &amp;&amp; Cumulative == 1) { int tag = ((Integer) arg0.getTag()); CurrentMeterReading = Integer.valueOf(Caption.getText() .toString()); CurrentReading =new HashMap&lt;String, Integer&gt;(); CurrentReading.put("Tag"+tag,CurrentMeterReading); getReading.add(CurrentReading); Log.i("Curr", "Current" + CurrentMeterReading); Log.i("Pre", "previous" + previousMeterReading); if (CurrentMeterReading &lt; previousMeterReading) { AlertDialog.Builder builder = new AlertDialog.Builder( context); builder.setTitle("WARNING"); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setMessage("Please Enter UserName"); builder.setPositiveButton("ok", new DialogInterface.OnClickListener() { public void onClick( DialogInterface dialog, int which) { // Caption.requestFocus(); } }); AlertDialog diag = builder.create(); diag.show(); // Caption.requestFocus(); // v = null; // Caption = null; }else if(Cumulative==0 &amp;&amp; !Caption.getText().toString().equals("")){ //int tag1 = ((Integer) arg0.getTag()); CurrentMeterReading = Integer.valueOf(Caption.getText() .toString()); CurrentReading =new HashMap&lt;String, Integer&gt;(); CurrentReading.put("Tag"+tag,CurrentMeterReading); getReading.add(CurrentReading); } } v = null; Caption = null; } } }); return view; } </code></pre>
 

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