android-adapter

Android - ArrayAdapter duplicates ListView items

馋奶兔 提交于 2019-12-12 15:17:01
问题 I have a ListView widget (positioned below other UI elements) that is part of an Activity that does not extend ListActivity . I am trying to write a basic feature that adds extra items to the ListView upon clicking a Button . This data is obtained from an EditText . I define the Adapter , an ArrayAdapter in my case, for the ListView in onCreate() and set the adapter for the ListView using setListAdapter() . However when I try to add an extra item to the ListView two items are added in the

OnBackpressed get empty view on tablayout

橙三吉。 提交于 2019-12-12 11:13:34
问题 Hey guys please look into the matter. I am stuck in solving this problem. I have set tabs in fragment using TabLayout and ViewPager . The problem is when i move to next fragment and then i press back button i get empty tabs view. Here I am attaching my code. home.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout

Efficient adapter has java.lang.ClassCastException?

只愿长相守 提交于 2019-12-12 10:05:33
问题 After watching here I try to implement my own efficient adapter, My ViewHolder class almost same: static class ViewHolder { ImageButton button; TextView txtView; } getView method look like: private void getView(...) { if(convertView == null) { convertView = LayoutInflater.from( parent.getContext()).inflate(R.layout.linear_container, parent, false); holder = new ViewHolder(); convertView.setTag(holder); } else { // erro line holder = (ViewHolder) convertView.getTag(); } LinearLayout

Null Pointer Exception : Attempt to invoke virtual method 'void

风流意气都作罢 提交于 2019-12-12 07:04:59
问题 I have problem with my code. I'm learning how to create Simple Firebase CRUD application with Android . Here is my MainActivity code : package com.ogigpermana.crudfirebaseapp; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.Spinner; import android.widget.Toast; import com.google.firebase.database

How to do put a CheckBox in a ListView?

断了今生、忘了曾经 提交于 2019-12-12 05:26:33
问题 I have a listview with a custon adapter. I the row's layout, I have a text and a checkbox. When I load the listview, I get the data from a database and it has one colunm that determine if the row is cheched or not. When I load the list, its ok, the rows that has to stay checked, stays checkd, and the others no. The problem is: when I unckheck a row ans roll the list down and up, when I return to the start, the row that I had unchecked, returns checked again, how can I resold this problem: The

How to use nested Listview in android

≡放荡痞女 提交于 2019-12-12 05:26:25
问题 I need to show data which contains a main object and has many child objects. Each child object has its view which contains checkbox and buttons having functionality. Giving demo design which I've done http://i.stack.imgur.com/ELB51.png But am not understanding how to create nested listview to populate data in this way. Picture showing 'Reminder 01' is first reminder data and there will be many reminder data each having their own doses data with checkbox and snooze button. Even I've done all

getBaseline of TextView returns -1

天涯浪子 提交于 2019-12-12 04:22:48
问题 I am trying to align two TextView one is inside HorizontalScrollView , and both are children of LinerLayout . When I am trying to call getBaseLine of TextView inside onWindowAttached of RecyclerView Adapter it always returns -1. Yes, the parent view of TextView , LinerLayout has android:baselineAligned="true" Edit : Adding Code Layout <LinearLayout android:id="@+id/linearLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android

How to set the Adapter for the circular Scroll-able tab

為{幸葍}努か 提交于 2019-12-12 03:49:54
问题 I am trying to set infinite view Pager( circular Scroll-able tab ) using Infinite ViewPager but when I tried to set the adapter 1.It work only from the end side ( last Position ). 2.It is not working on the start( position 0 ) side. 3.It repeat the last fragment when scrolled further. My adapter private InfiniteViewPager pager = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); pager =

How to create an interface between an adapter and a viewholder

谁说胖子不能爱 提交于 2019-12-12 03:48:57
问题 I want to create an interface between an adapter and a view holder (this view holder is an inner class of another adapter) so that I can update the text view (number). How can I do this? In detail: I have two recycle views (Main List Recycler View and Sub List Recycler View horizontally placed as shown in the fig) one having a number (as one of its item) and other having checkbox (as its item). I have two adapters FilterMainListAdapter and FilterSubListAdapter with view holders

how to make android recycler views adapter accept different data types?

╄→гoц情女王★ 提交于 2019-12-12 03:38:00
问题 i have a lot of recycler views, they all use the same adapter, i used to update them with arraylists of objects that id make as i went like this ADAPTER private List<CardWriter> cardMakerList; public CardAdapter(List<CardWriter> cardMakerList){ this.cardMakerList = cardMakerList; // this.mContext = context; } ACTIVITY public List<CardWriter> cardMakerList = new ArrayList<>(); public CardAdapter cardAdapter; recyclerView.setAdapter(cardAdapter); CardWriter cardWriter = new CardWriter