1
votes

onItemClickListener has following arguments onItemClick(AdapterView arg0, View arg1,int arg2, long arg3) I am getting correct result from arg2 i.e. number of item which is selected but when i try to access string value from view program is crashing

    public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3) 
        {
            String s = ((TextView)arg1).getText().toString();
            try
            {
                Log.v("----","ActionListener called"+arg2);
            }
            catch(Exception E)
            {
                Log.v("----","unable to get Text from Text field "+arg2);
            }
        }

when I comment Statement String S... code does not crash

1
can you add your row file? Means how you designed your list itemShankar Agarwal
or else the code how you are framing adapter. i need you arraylistShankar Agarwal
Yes I was able to add rows, problem was only in definition of Adapter where I passed wrong arguments B/w thanks for helpuser1349746

1 Answers

0
votes

Problem is not in this code, i had similar problem and actually problem was in the definition of adapter try changing definition of adapter and it will work

ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_single_choice, android.R.id.text1, Values);