android-adapter

Get RecyclerView last visible item

穿精又带淫゛_ 提交于 2019-12-11 08:49:17
问题 findLastVisibleItemPosition returns -1 with the following sequence: onViewCreated() { recyclerView.setAdapter(adapter = new Adapter()); adapter.updateContent(List<Content>); // will call notifyItemRangeChanged post(new Runnable() { run() { layoutManager.getLastVisibleItem(); // == -1 (using runnable or not) } } } It seems that the children views are not ready yet. Using a tree observer on the RecyclerView seems to solve the problem, but what would be the best approach to get the last visible

How do I make the ListView clickable and show some text once it gets clicked?

给你一囗甜甜゛ 提交于 2019-12-11 08:05:14
问题 I am practicing ListView and I have placed a few List Items on an activity. Right now I have 3 items of list (in three rows). I want that once a user click one of the row (let's say it's my first row for now) s/he should be able to see some details text about it. That text will be displayed somewhere at at the bottom of the activity , outside the ListView.How could I do that? Like this: I am working on this code: MainActivity.java: public class MainActivity extends ActionBarActivity {

Check a list view item from adapter when long clicked

倖福魔咒の 提交于 2019-12-11 07:35:11
问题 I have a listview for a note application set with my adapter. The list view component consists of some textviews and a checkbox which pops up delete icon when a listview item is long clicked. Am automatically making the checkboxes visible from the adapter when the delete icon becomes visible so that the user could select the items he wants to delete. The problem is i want a single list item to be automatically checked when long clicked. How do i go about this? My logic does not work.

Listview button click issue in android

我的梦境 提交于 2019-12-11 07:11:35
问题 I'm using a list view and there is a button called "Order" in the list item. I want to show a "tick" image when the user presses the button and hide it when the user presses the button again. My issue is when I clicked on the button on the first item, tick image of the 4th and 8th item is also appeared. This is the onClickListener in the adapter, viewHolderItem.btnOrder.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean isSelected = shoe.isSelected();

Spinner with custom layout doesn't show nothing Android

前提是你 提交于 2019-12-11 06:37:57
问题 in my application I must use a spinner that should show three items (IT,EN,PR). I must also use a personalized layout. The code is in an another adapter in onCreate method: holder.spinnerLenguage = (Spinner) convertView .findViewById(R.id.spinnerLenguage); ArrayList<String> spinnerArray = new ArrayList<String>(); spinnerArray.add("IT"); spinnerArray.add("EN"); spinnerArray.add("PR"); final lenguageSpinnerAdapter lenguageAdapter = new lenguageSpinnerAdapter( convertView.getContext(),

RecyclerView reload same data when refresh

坚强是说给别人听的谎言 提交于 2019-12-11 06:13:16
问题 I have a problem, when i swipe to refresh the data, the first swipe is ok but after that every swipe reload and add the same data over and over again, by the end i have a list with same items over and over... I'm using a loader. I tried to clear before but i don't understand what's wrong with my code, if someone could explain it to me. Thank You. Here my code : public abstract class NewsFragment extends Fragment implements LoaderManager.LoaderCallbacks<ArrayList<Articles>> { protected

Why the compiler ask me declare a variable “final” when I use the method “OnClickListener” on adapter class? [duplicate]

孤街醉人 提交于 2019-12-11 05:18:19
问题 This question already has answers here : Why are only final variables accessible in anonymous class? (13 answers) Closed 5 years ago . I have an adapter class, I have a checkbox in this layout and with "OnClickListener" method I try to declare "check = true" but the ADT ask me declare a final the ViewHolder This is my adapter class public class MaterialAdapter extends ArrayAdapter<MaterialModel> { public MaterialAdapter(Context context, int resource, List<MaterialModel> objects) { super

BaseAdapter's getView getting wrong position

不羁岁月 提交于 2019-12-11 04:39:08
问题 I have this weird problem with position variable inside getView method of the adapter. 4 of those 6 different view types, got a button inside them. That button sends a message to a service (provoking some async stuff on the service), and within an indefinite amount of time after, this adapter gets a notifyDataSetChanged() provoked by the service. The problem shows when i spam the button that sends the message. If i spam it fast enough, the wrong position will be sent to the service. I think

Android RecyclerView: why is first item in list already selected?

痴心易碎 提交于 2019-12-11 04:28:13
问题 I have a RecyclerView list of CardViews with a defaultbackground of white. I set up a OnLongClickListener to select the CardView and load a DialogFragment to confirm deletion for the item (CardView) and change the background color to red. Everything is working correctly except the first CardView created in the list is already showing a red background even though the user has not OnLongClicked the CardView. Thereafter, the newest CardView added always shows the red background even when the

How to set the adapter for an inner RecyclerView item without skipping the layout?

你离开我真会死。 提交于 2019-12-11 04:27:20
问题 I'm using a RecyclerView to display some data. For each item in my RecyclerView I have created a custom layout which holds beside other views a RecyclerView. So I have a nested RecyclerView under each item. <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:layout_width="180dp" android:layout_height="45dp" android:id="@+id/recycler_view"/> //Other text views </RelativeLayout> The layout for the inner