android-adapter

“RecyclerView: No Adapter attached; skipping layout” for recyclerview in fragment [duplicate]

僤鯓⒐⒋嵵緔 提交于 2019-12-30 06:07:17
问题 This question already has answers here : recyclerview No adapter attached; skipping layout (30 answers) Closed 3 years ago . I'm getting this error but I don't know what is causing it...perhaps something to do with the fact that this is being initialized in a fragment and not in the activity itself. Edit: included StatsAdapter code public class StatsFragment extends Fragment { private RecyclerView mRecyclerView; private LinearLayoutManager mLinearLayoutManager; private RecyclerView.Adapter

android notifyItemRangeInserted disable autoscroll

心已入冬 提交于 2019-12-30 00:53:08
问题 I'm using RecyclerView as the base for my data list. i've implemented custom RecyclerView.Adapter which is based on ArraList. on fetching data from the internet the code that i'm running is: public void addItems(List<Item> items){ final int size = data.size(); data.addAll(items); notifyItemRangeInserted(size, items.size()); } Problem is that for after running this code i'm getting an autoscroll to the bottom of the list (last element is now visible) Is there a way to disable this? couldn't

How to update/refresh specific item in RecyclerView

∥☆過路亽.° 提交于 2019-12-28 03:24:07
问题 I'm trying to refresh specific item in RecyclerView . Story: Whenever user clicks on item, it shows AlertDialog . User can type some text by clicking ok button. I want to show this text in this item and show invisible ImageView - declared in XML and adapter ViewHolder - I used this function in AlertDialog Positive Button to update the item: private void updateListItem(int position) { View view = layoutManager.findViewByPosition(position); ImageView medicineSelected = (ImageView) view

Different row layouts in ListView

血红的双手。 提交于 2019-12-28 03:00:50
问题 This post is related to this ViewHolder not working. On that post, I was following a tutorial on how to use ViewHolder on a ListView . What I want now is to have the last item on a ListView to have a different layout than the rest. Here's my code: int lastpos = mList.size()-1; System.out.println("position: "+position+" mlist: "+lastpos); if(position==lastpos){ view = vi.inflate(R.layout.list_item_record, null); holder.textView = (TextView)view.findViewById(R.id.record_view); }else{ view = vi

Listview : Getting the text of the selected row

混江龙づ霸主 提交于 2019-12-25 17:16:34
问题 I have a listview with an image and a textview in each row. I want to get the value of the text on the clicking of the whole row. Below code is behaving strange.I am getting the value of random row instead of the one clicked. I am not getting what is wrong. Any help would be appreciated. I am doing this, : public static class LazyAdapter extends BaseAdapter { private Activity activity; private ArrayList<HashMap<String, String>> data; private static LayoutInflater inflater=null; public

Listview : Getting the text of the selected row

佐手、 提交于 2019-12-25 17:16:11
问题 I have a listview with an image and a textview in each row. I want to get the value of the text on the clicking of the whole row. Below code is behaving strange.I am getting the value of random row instead of the one clicked. I am not getting what is wrong. Any help would be appreciated. I am doing this, : public static class LazyAdapter extends BaseAdapter { private Activity activity; private ArrayList<HashMap<String, String>> data; private static LayoutInflater inflater=null; public

Problems with nested Recylerview

妖精的绣舞 提交于 2019-12-25 17:06:34
问题 I have data from Firebase data like below: My problem is my RecyclerView display not as expected. The data of my messages were accumulated, it should go one part by one part and should not be accumulated. I do not know how to explain properly since it has so much codes. My current output shown as below: Ask Teacher List Page: package xxx.xxx.my.package import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Build;

Adjust GridView with ImageViews to different screen sizes, Android

旧街凉风 提交于 2019-12-25 16:47:47
问题 I'd so appreciate if someone could advise on below. My GridView has 3 columns that will be filled with ImageViews: <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/grid_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:layout_marginRight="10dp" android:layout_marginLeft="10dp" android:numColumns="3" android:columnWidth="0.3dp" android:horizontalSpacing="20dp"

Insert images in listview of Adapter class according to the condition of Main Activity class

一笑奈何 提交于 2019-12-25 07:29:04
问题 My title might seems unclear to you. Due to new in Java and lack of logic I want to ask you simple thing. I have a Activity class, where there is list of trainings with two text views and one image view. OnClick to the listView I want to go to the next activity in some conditions. That condition you can see below in code. Activity class; public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { currentTraining = (Training) arg0.getAdapter().getItem(arg2); SharedMemory

Creating an adapter for listview without passing an array initially

[亡魂溺海] 提交于 2019-12-25 07:04:58
问题 I have a a customer adapter ( SongsAdapter ) that extends ArrayAdapter and it contains an array of Song objects. In my fragments onCreateView method I'm trying to initialize this adapter. adapter = new SongsAdapter(getContext(), arrayOfSongs); the problem is that arrayOfSongs is initially null. The user should search for a song on the iTunes database and when I get a response, I parse the JSON and create song objects and then add them to my adapter adapter.addAll(songs); and then adapter