Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I avoid calling of getView() method of adapter class when I tap on listitems?
    primarykey
    data
    text
    <ul> <li>I have implemented list view having buttons having background image changing effects.but, when I tap on any list item, that effect is no longer present there and get refreshed.</li> <li>I checked that, when I tap on any list item, that getView() is calling...</li> <li>How to avoid this???</li> <li>please suggest any solution if anyone knows...</li> <li>Thank you..</li> <li>code is :</li> </ul> <p>public class EventListAdapter extends BaseAdapter { private static final int VISIBLE = 0;</p> <pre><code>private static final int GONE = 8; private List&lt;Events&gt; dateForEventList; private String eventsRetrived; private String[] events; boolean clickStatus = false; private int status = 0; public EventListAdapter(Context context) { mContext = context; } /** * The number of items in the list is determined by the number of announcements * in our array. * * @see android.widget.ListAdapter#getCount() */ public int getCount() { DatabaseManager db = new DatabaseManager(mContext); dateForEventList = db.getAllData1(CalendarAdapter.dateOfEventSingle); for (Events l : dateForEventList) { eventsRetrived = l.getEventData(); } events = eventsRetrived.split(","); return events.length; } /** * Since the data comes from an array, just returning * the index is sufficent to get at the data. If we * were using a more complex data structure, we * would return whatever object represents one * row in the list. * * @see android.widget.ListAdapter#getItem(int) */ public Object getItem(int position) { return position; } /** * Use the array index as a unique id. * @see android.widget.ListAdapter#getItemId(int) */ public long getItemId(int position) { return position; } public View getView(final int position, View myView, ViewGroup parent) { if(myView == null) { LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); myView = inflater.inflate(R.layout.activity_event_list, null); } TextView textViewTitle; TextView textViewDialogue; final ImageButton buttonForCheckMark; final ImageButton buttonForDelete; final ImageButton buttonForRemainder; //Events event = new Events("11/2/2013","today, there is function in Shivajinagar"); // event.setDate("11 Jan,2013"); // String event1 = event.getDate(); // // textViewForDateHeader = (TextView)myView.findViewById(R.id.textViewHeadingDate); // textViewForDateHeader.setText(event1); DatabaseManager db = new DatabaseManager(mContext); dateForEventList = db.getAllData1(CalendarAdapter.dateOfEventSingle); for (Events l : dateForEventList) { eventsRetrived = l.getEventData(); } events = eventsRetrived.split(","); // TextView tv = (TextView)myView.findViewById(R.id.grid_item_text); // tv.setText(events[position]); textViewTitle = (TextView) myView.findViewById(R.id.textViewTitle); textViewTitle.setText(events[position]); textViewDialogue = (TextView) myView.findViewById(R.id.textViewDialog); textViewDialogue.setText(events[position]); textViewDialogue.setVisibility(mExpanded[position] ? VISIBLE : GONE); // textViewHeader = (TextView)myView.findViewById(R.id.textViewHeader); // textViewHeader.setText(mHeader[position]); // textViewHeader.setVisibility(mExpanded[position] ? VISIBLE : GONE); buttonForCheckMark = (ImageButton) myView.findViewById(R.id.buttonForCheckMark); buttonForCheckMark.setVisibility(mExpanded[position] ? VISIBLE : GONE); buttonForDelete = (ImageButton) myView.findViewById(R.id.buttonForDelete); buttonForDelete.setVisibility(mExpanded[position] ? VISIBLE : GONE); buttonForRemainder = (ImageButton) myView.findViewById(R.id.buttonForRemainder); buttonForRemainder.setVisibility(mExpanded[position] ? VISIBLE : GONE); buttonForRemainder.setOnClickListener(new OnClickListener() { @SuppressWarnings("static-access") @SuppressLint("SimpleDateFormat") public void onClick(View v) { try { Toast.makeText(mContext, "remainder saved..", Toast.LENGTH_SHORT).show(); } catch (Exception ex) { Toast.makeText(mContext, "Exception in Remainder " + ex.toString(), Toast.LENGTH_SHORT).show(); } // } }); buttonForCheckMark.setOnClickListener(new OnClickListener() { public void onClick(View v){ Toast.makeText(mContext, "tapped on checkMark", Toast.LENGTH_SHORT).show(); Toast.makeText(mContext, " current Position tapped : " + position, Toast.LENGTH_SHORT).show(); if(position == 0) { buttonForCheckMark.setBackgroundResource(R.drawable.ic_launcher); buttonForDelete.setBackgroundResource(R.drawable.ic_navigation_cancel); buttonForCheckMark.setClickable(false); buttonForDelete.setClickable(true); } // change the status to 1 so the at the second clic , the else will be executed // else { // button.setBackgroundResource(R.drawable.ic_navigation_accept); // status =0;//change the status to 0 so the at the second clic , the if will be executed // } // buttonForCheckMark.setBackgroundResource(R.drawable.ic_drawer); } }); buttonForDelete.setOnClickListener(new OnClickListener() { public void onClick(View v) { Toast.makeText(mContext, "tapped on delete", Toast.LENGTH_SHORT).show(); if(position == 0) { buttonForCheckMark.setBackgroundResource(R.drawable.ic_navigation_accept); buttonForCheckMark.setClickable(true); buttonForDelete.setBackgroundResource(R.drawable.ic_drawer); buttonForDelete.setClickable(false); // change the status to 1 so the at the second clic , the else will be executed } } }); return myView; } public void toggle(int position) { mExpanded[position] = !mExpanded[position]; notifyDataSetChanged(); } /** * Remember our context so we can use it when constructing views. */ private Context mContext; /** * Our data, part 1. */ private String[] mTitles = { "Event 1", "Event 2", "Event 3", "Event 4", "Event 5" }; /** * Our data, part 2. */ private String[] mDialogue = { "wuszuogwfuieffufuhuysugdueljwihadghgxdhgyhghsdgyigwuweyuqaGDHGYHGHGAdhgyhigxgxgeuyehu.", "dgusduugyujguegytgujgdugwjhiuyg7wtqUYGYYgyijyiufufjguhgdugfhgfhgfgfhgfhghfghifgyi,dgwsdtgyfytfiuwt,", "rtygygghtudggyjhgujtugdhhguyuaUUUUDJYUIDHUJHDIIDUJDHDUJHDIDIOUYhujtdugyhdgg", "gjhuwjsgudggdudgjqhasdgdhgjdhushjaguhguwegagsdgygydgfgdcgycg", "fhdgyhdfhfgdyhhwsddgyuduuufguugwugdfgugdgooduiuduiuduuduiuiuidudiiwdiou" }; /** * Our data, part 3. */ private boolean[] mExpanded = { false, false, false, false, false, false, false, false }; // private Integer[] mThumbIds = { // R.drawable.remainder, R.drawable.remainder, // R.drawable.remainder, R.drawable.remainder, // R.drawable.remainder // // }; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    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.
    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