android-adapter

How to add section separators / dividers to a ListView?

我的梦境 提交于 2019-11-27 10:47:42
问题 I'm currently making a menu for my app, using a DrawerLayout and an ArrayAdapter subclass to achieve something looking like Facebook's drawer menu. I currently have no problems creating the list, but now that it looks good, i'd like to add separators between different kind of options (i.e. user-related and application-related options) and a search bar on top of the menu. The code of my current ArrayAdaptor subclass is as following : public class DrawerMenuAdapter extends ArrayAdapter<String>{

What's the role of adapters in Android?

走远了吗. 提交于 2019-11-27 10:04:25
I want to know when , where and how adapters are used in the context of Android. The information from Android's developer documentation was insufficient for me and I'd like to get a more detailed analysis. success_anil Well adapters in Android are basically a bridge between the UI components and the data source that fill data into the UI Component For example, Lists (UI Component) get populated by using a list adapter, from a data source array. Prashant_M Let’s assume you want to display a list in your Android app. For this you will use the ListView provided by Android. ListView s don’t

ListView or TableLayout?

淺唱寂寞╮ 提交于 2019-11-27 09:46:46
问题 I am really confused now as to which one to learn. I am an iPhone app developer and now learning Android development. I have learnt how to use a ListView with a static array of strings using an Adapter . I am used to using custom cells in iPhone, mostly for showing dynamic content like images and text in TableView s. So which is the way to go for doing that in Android? TableLayout or ListView ? 回答1: As others have already said in comments, you need to clearly define what you want to do first

Different row layouts in ListView

孤人 提交于 2019-11-27 08:57:25
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.inflate(R.layout.list_item_bn, null); holder.textView = (TextView)view.findViewById(R.id.tv_name); }

Android: Radio button in custom list view

a 夏天 提交于 2019-11-27 07:00:34
I am developing an application in which I need to implement radio buttons in list view. I want to implement a list view having one radio button and two text view in each row. And one button "Ok" below listview. What I have done is I created a list view and a custom adapter. The code of listview is as: <ListView android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:cacheColorHint="#00000000" android:overScrollMode="never" tools:ignore="NestedScrolling" android:choiceMode="singleChoice" > </ListView> And I created a custom adapter layout as: <

how to maintain Visibllity of recyclerview item in adapter class

不羁的心 提交于 2019-11-27 04:53:45
问题 I have a layout like bellow in my Adapter : <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#FFFFFF"> <android.support.v7.widget.CardView android:id="@+id/cardVisibleLayout" android:layout_width="match_parent" android:layout

Popup Menu in custom ListView

为君一笑 提交于 2019-11-27 04:26:05
问题 What I want to achieve: I have a custom ListView adapter. To each Listitem I want to add a popup menu, pretty similar to the ListView in the current Google Play application. This is what I tried: Most of my code comes from this Android sample samples\android-19\ui\ActionBarCompat-ListPopupMenu CustomFragmentPageAdapter.java : // create new fragment mCustomFragment = CustomFragment.newInstance(position); CustomFragment.java public class CustomFragment extends ListFragment implements View

ListView Adapter with arbitrary number of row types (Don't know the number of different row types)

末鹿安然 提交于 2019-11-27 04:07:24
问题 So, I am making this application. The application parses a website, or more specifically a vbulletin-board. When I'm parsing a thread in the forum, I have divided it up so that when I parse each post in that thread, I get the actual content of the post in sections such as this, and I store the sections in the correct order in an array: [Plain text] [Quote from somebody] [Plain text] [Another quote] [Another quote again] [Some more plain text] However, a post can be arranged in any order as

RecyclerView Adapter notifyDataSetChanged not working

半城伤御伤魂 提交于 2019-11-27 03:45:30
问题 I extended RecyclerView.Adapter<RecyclerView.ViewHolder> And when I called: mRecyclerView.getAdapter().notifyDataSetChanged(); Nothing happened. The only way to refresh the view is to set again the adapter (see this answer): mRecyclerView.setAdapter(new MyAdapter(...)); I have two issues with this solution: I can see a blink on the screen when I set again the adapter The listview returns to the first position. Any ideas? 回答1: If notifyDataSetChanged() does not trigger view updates than there

ListView updated from EditText

放肆的年华 提交于 2019-11-27 03:41:34
问题 I have a Custom Listview that it is updated from a EditText component in a dialog. I have the custom row, the adapter class and the custom dialog all working but I can't seem to trigger the code in the adatper class that would add the text from the edit text control to the list. Here is my activity code, let me know if you want the adapter code. It worked before I added the custom row and adapter to the list :( Symptom of problem: emailAdapter.notifyDataSetChanged(); does nothing public class