1

OnClickListner is not working!

I have two text view in each row of my list view which is in Fragmnet. I want to pass the ID of the particular row onClick which is not working.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_news, container, false);
    newsListView = (ListView) view.findViewById(R.id.news_list);
    newsListView.setClickable(true);
    newsList = new ArrayList<>();
    newsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0,View arg1, int position, long arg3) {
            System.out.println(position);

        }
    });
    loadNewsList();
    getActivity().setTitle("News");
    newsListView.setClickable(true);
    return view;
}

i get this in console on click

D/ViewRootImpl@19f3c4b[MusicActivity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 530252349440}
D/ViewRootImpl@19f3c4b[MusicActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true 530252349440} surfaceGenerationChanged=false
D/ViewRootImpl@19f3c4b[MusicActivity]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@19f3c4b[MusicActivity]: ViewPostImeInputStage processPointer 1
shank
  • 159
  • 7
  • 1
    refer https://stackoverflow.com/questions/25713219/why-is-hardware-acceleration-not-working-on-my-view – sasikumar Dec 24 '18 at 06:58
  • 1
    Thanks for your response...i am not able to find solution here! can u help me out in any other way? @sasikumar – shank Dec 24 '18 at 07:07
  • did you debug it? – sasikumar Dec 24 '18 at 07:09
  • 1
    Yes i did. i get these lines on click of my list view , D/ViewRootImpl@19f3c4b[MusicActivity]: ViewPostImeInputStage processPointer 0 D/ViewRootImpl@19f3c4b[MusicActivity]: ViewPostImeInputStage processPointer 1 – shank Dec 24 '18 at 07:17
  • refer https://stackoverflow.com/questions/22705760/listview-setonitemclicklistener-not-working-in-custom-list-view – sasikumar Dec 24 '18 at 07:19
  • now i added android:clickable="true",android:focusable="false" android:focusableInTouchMode="false" ,i still have the same problem. – shank Dec 24 '18 at 07:32
  • try adding ` newsListView.setClickable(true);` before setting the click listener. – Farouk Dec 24 '18 at 08:11

1 Answers1

2

Problem with XML files . Please share those .