Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes not work OnItemClick when I use two Activity
    primarykey
    data
    text
    <p>Hello I have two activities with ListViews, I can call second activity from first but when I close second activity and return to first activity, OnItemClick doesn't work, So you know where is problem and how to solve it?</p> <p>first activity onCreate </p> <pre><code> @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.add_words_activity); list=(ListView) findViewById(R.id.add_words_list); getClassData(); wordItems=new ArrayList&lt;WordItem&gt;(); adapter=new AddWordsAdapter(this, wordItems); list.setAdapter(adapter); list.setOnItemClickListener(itemClick); list.setOnTouchListener(listViewTouchListener); } </code></pre> <p>first activity ItemClick</p> <pre><code> private OnItemClickListener itemClick=new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; adapter, View view, int position, long id) { isEditWordDilaog=true; start=words.get(position); Log.d(start.getWord(),"what the fuck"); end=new WordData(); final int langId=start.getLanguageId(); end.setLanguageId(langId); showDialog(WORD_DIALOG); wordViewHolder.language.setImageResource(RProvider. getLangImageId(languages.get(langId))); wordViewHolder.word.setText(start.getWord()); wordIndex=position; } }; </code></pre> <p>first activity on touch:</p> <pre><code> private OnTouchListener listViewTouchListener =new OnTouchListener() { float startX,endX; boolean isMove=false; @Override public boolean onTouch(View view, MotionEvent event) { int action=event.getAction(); switch(action){ case MotionEvent.ACTION_DOWN: startX=event.getX(); break; case MotionEvent.ACTION_MOVE: isMove=true; break; case MotionEvent.ACTION_UP: endX=event.getX(); if(isMove==true &amp;&amp; startX&lt;endX){ Rect rect=new Rect(); int endY=(int)event.getY(); for(int i=0;i&lt;list.getChildCount();i++){ View child=list.getChildAt(i); int left=child.getLeft(); int right=child.getRight(); int bottom=child.getBottom(); int top=child.getTop(); rect.set(left, top, right, bottom); if(rect.contains((int)endX,endY)){ Intent intent=new Intent(AddWordsActivity.this,AddTranslateActivity.class); int id=words.get(i).getId(); intent.putExtra(Names.WORD_ID,id); startActivity(intent); break; } } } /* endX=event.getX(); if(startX&lt;endX){ isMove=true; }*/ break; } isLongClick=!isMove; return isMove; } }; </code></pre> <p>In second activity I use back button for close it. after than itemClick doesn't not work</p>
    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.
    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