Note that there are some explanatory texts on larger screens.

plurals
  1. POcustom list in android crash
    primarykey
    data
    text
    <p>i create custom list but when i run this, application crash , what is problem in it , please tell me. and i wand to the functionally , when i press "+" button , it increase the count of EditText by one and when i press "-" button then it decrease the count of EditText by one .. any one tell me what is the problem whit this piece of code . which create custom list ..</p> <p>list XML file </p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" &gt; &lt;ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" &gt; &lt;/ListView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>container XML file , which contain the button etc</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/tvTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="1kg" /&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="5" &gt; &lt;Button android:id="@+id/btnSubtract " android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="-" /&gt; &lt;EditText android:id="@+id/etQuantity" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:ems="10" android:inputType="number" &gt; &lt;requestFocus /&gt; &lt;/EditText&gt; &lt;Button android:id="@+id/btnAdd" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="+" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>main java class</p> <pre><code>package com.example.custoplist; import android.os.Bundle; import android.app.Activity; import android.app.ListActivity; import android.content.Context; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends ListActivity { String[] itemsList= {"1/2 kg","1 kg", "5 kg", "10 kg", "16 kg"}; String[] itemQuantity = new String[5]; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setListAdapter(new MyAdapter(this, android.R.layout.simple_list_item_1,android.R.id.text1,itemsList)); } private class MyAdapter extends ArrayAdapter&lt;String&gt;{ public MyAdapter(Context context, int resource, int textViewResourceId, String[] objects) { super(context, resource, textViewResourceId, objects); // TODO Auto-generated constructor stub } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub //return super.getView(position, convertView, parent); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.content, parent, false); TextView tvTitle = (TextView) findViewById(R.id.tvTitle); EditText etQuantity = (EditText) findViewById(R.id.etQuantity); Button btnAdd = (Button) findViewById(R.id.btnAdd); Button btnsSubtract = (Button) findViewById(R.id.btnSubtract); tvTitle.setText(itemsList[position]); return row; } } } </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.
    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