Questions tagged adapter

Explore the latest questions and answers asked by our top developers.

Set adapter for listview in fragment instead of activity

Hello! I have tried to add a listview in a fragment but it doesn´t accept getApplicationContext: adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, arrayList); and this: Toast.makeText(Todo.this, "" + parent.getItemAtPosition(position), Toast.LENGTH_SHORT).show(); How do I make it work for fragment instead of activity? Code: public class Todo extends Fragment { EditText editText; Button button; ListView listView; ArrayList<String> arrayList; […]

By Lina Harald zz
Published
Categorized as adapter, android, fragment, java

Firestore data not showing in recycler view

I am trying to add data in my recycler view from firestore. I have documents with name (Level+"levelNo.") But nothing is showing on my activity Here is the code: MAIN LEVEL ACTIVITY: public class LevelActivity extends AppCompatActivity { // Recycler View object RecyclerView recyclerView; // Array list for recycler view data source public static List<String> […]

How to set Text button

i have a custom_layout_dish <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="100dp" android:layout_gravity="center" android:weightSum="10"> <ImageView android:id="@+id/img_Dish" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="6" android:src="@drawable/dau_phu_luot_van"/> <LinearLayout android:padding="10dp" android:layout_weight="3.5" android:layout_gravity="center" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/tv_NameDish" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Pepsi"/> <TextView android:id="@+id/tv_Price" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="30.000"/> </LinearLayout> <Button android:id="@+id/btn_Order" android:layout_gravity="center" android:layout_weight="0.5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_add"/> </LinearLayout> and activity_orderfood <Button android:id="@+id/btn_Cart" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="Xem Hóa Đơn" /> <ListView android:id="@+id/lv_dish" […]

By Levents
Published
Categorized as adapter, android

CusrsorAdapter extend two static class to hold two views

I have cursor adapter which extends one static class with one View public class CursorRecyclerViewAdapter extends CursorAdapter<CursorRecyclerViewAdapter.CursorHolder> { @Override public CursorHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(id, parent, false); return new CursorHolder(itemView, parent) } } static class CursorHolder extends RecyclerView.ViewHolder { } static class CursorHolder2 extends RecyclerView.ViewHolder { } How can […]

By Slava Vir
Published
Categorized as adapter, android, cursor, extends, view

Сan you tell me why FragmentManager has not been attached to a host?

I’m trying to connect swipes to navigationbottomview, but so far I’m stuck on a basic adapter and can’t figure out what’s the matter, please tell me why it knocks out an error: java.lang.IllegalStateException: FragmentManager has not been attached to a host. Everything works fine until I plug in the adapter. Here is my code: public […]

By Binary
Published
Categorized as adapter, android, android-viewpager2, java

Moving an Adapter Object from one activity to another

I want to move an adapter object from one activity to another. My main activity: Intent intent = new Intent(MainActivity.this, ActivityTest.class); intent.putExtra("Key1", position); intent.putExtra("key2", toyAdapter); startActivity(intent); My second activity: Intent intent = getIntent(); int position = intent.getIntExtra("Key1", 0); ToyAdapter toyAdapter = (ToyAdapter) intent.getSerializableExtra("Key2"); I know something’s wrong but I am pretty new to this and […]

By Ilay
Published
Categorized as adapter, android, android-studio, java

Connect viewmodel class to adapter(recyclerview)

I have viewModel class which name UserListViewModel And on that class there is function which named sumUserIncrease and I want to get that functions value and send that to adapter to show in recyclerview I hope you got what I mean if not, take look at this: here is my userListViewModel: class UserListViewModel( val mUserInfoDAO: […]

By AmirAndroidDeveloper
Published
Categorized as adapter, android, android-recyclerview, kotlin, viewmodel

why spinner disappear sometimes and reappear again after Minimizing the app?

i am trying to make web devoloping app but i am facing problem in the spinner, its disappear some times and i dont know the reason.. this when i set the adapter to the spinner:- https://i.stack.imgur.com/xE63u.png and this when i minimize the app and open it again:- Source: Android Questions

By Star4Droid
Published
Categorized as adapter, android, java, spinner, view

Attempt to invoke interface method ‘…Interfaces.NotificationCounter.increaseNotification()’ on a null object reference (not a duplicate)

NotificationCounter Interface : public interface NotificationCounter { public void increaseNotification(); } MainActivity.java : public class MainActivity extends AppCompatActivity implements NotificationCounter { protected void onCreate(Bundle savedInstanceState) { … PostAdapter postAdapter = new PostAdapter(this); … } public void increaseNotification(){ //code } } PostAdapter : public class PostAdapter extends RecyclerView.Adapter { private ArrayList<Post> posts; private Context context; private […]

By Krishna Jindal
Published
Categorized as adapter, android, android-studio, java, nullpointerexception

android recyclerview adapter partial update

I’ve got a list of URLs, which I use to download data inside a LoaderManager. Then, I want to pass all those data on the recyclerview adapter. According to android documentation, I need to load the data on the background (by overriding the loadInBackground method) and update the adapter on the main thread (by overriding […]

By LazyAnalyst
Published
Categorized as adapter, android, android-recyclerview, background, multithreading
1 2 3 32

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq