3

I am trying to set On Click Listener on the List view. I have used the View holder and Base Adapter for Inflating the List view . I have used following Code:: Myonclicklistneer

myonclicklistneer = new Myonclicklistneer();
listView.setOnItemClickListener(myonclicklistneer); 

//Listneer Is 
class Myonclicklistneer implements OnItemClickListener
    {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) {
            Log.i("MyLog", "DONE DONE Listneer Is set!!!");

        }

    }

What is my problem that Listneer is setting and I am Inflating 3 Text View and 1 EditText.Whenever I click on any of the widgets in the row Listener has to be set.

0

2 Answers 2

5

Add android:focusable="false" to other view of the ListView to make ListView Clickable.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Lalit It's working properly... for the Text view But for the Edit text It is not working. On the Edit text I have set the Textwatcher separately. EditTextWacher editTextWacher = new EditTextWacher(viewHolder); viewHolder.editTextQuantity.addTextChangedListener(editTextWacher); How to listener on the Edittext 90% Requirement is set now 10 % is pending It depends upon the Edittext...
@mayurrahatekar You should ask this as seprate question,Or update the main question.
4

As I understand it, you have created your own custom Adapter by extending BaseAdapter.

Instead of setting an OnItemClickListener you should set an OnClickListener on each view inside the getView()-method of your Adapter.

Add the OnClickListener to your Adapter-class as an inner class:

private class MyOnClickListener implements OnClickListener
{
  @Override
  public void onClick(View view) {
     //Do what needs to be done.
  }
}

Then inside your getView()-method:

public View getView() {
   //Inflate the view and get references to your TextViews/EditText.
   TextView text = (TextView) view.findViewById( R.id.myListItemTextView );

   //Set the onClickListener for each of the TextViews/EditTexts.
   text.setOnClickListener( new MyOnClickListener() );
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.