adapter

Toast not generating text from selected item from list

只谈情不闲聊 提交于 2019-12-02 11:08:30
问题 I've made a simple app in android with list View,In that i want to make a toast when select an item,i have tried as below but its not working.. my code is as below: main.java package com.example.listview; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Bundle; import android.app.Activity; import android.app.ListActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import

How to refresh a view in main activity from an adapter?

半城伤御伤魂 提交于 2019-12-02 08:46:37
I have a graph in main activity also I have a recycler view in main activity. Custom adapter is used for recyclerview. I have a check box and swipe layout in list item layout. in swipe layout there is a delete button. I want to reset the graph of main activity when I check the check box or when I delete any item. For this I created one method in main activity. And called this method in adapter onCheckedChangeListener and on click of delete. But I am getting a null pointer exception on mBarChart. i.e . graph. I have instantiated in mBarChart in setUI method and this is called in onCreate of an

Dynamic list view with a dynamic adapter

家住魔仙堡 提交于 2019-12-02 08:45:23
I want to create a dynamic listview which adds dynamic elements on scrolling to the end of the initial list. New items should be added everytime the scroll position reaches the end of previous list. How can I achieve this? Thank you. you need to add a scroll listener and override the onscroll() 来源: https://stackoverflow.com/questions/9454170/dynamic-list-view-with-a-dynamic-adapter

How can I Reuse Methods for ListViews?

与世无争的帅哥 提交于 2019-12-02 08:28:23
问题 I have several methods in the ListAC ListActivity that I want to reuse and would like to put in separate classes (if possible??). I will be having dozens of ListView Activities (ListActivities ie: ListAD, ListTCDS, listSFAR, etc., etc.) that will call on these methods that are exactly the same in this activity but the only changes in the 'Cursor databaseCursor' (ie. The Table name for each ListActivity). I plan on putting these Classes and related into their own packages w/n the application

FATAL EXCEPTION: main android java

馋奶兔 提交于 2019-12-02 07:36:24
I want to populate listview through adapter using array like below: public class ChildActivity extends ActionBarActivity implements GetChildList { private ListView lv_child; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_child); List<String> array = new ArrayList<String>(); // for e.g array ["num1", "num2"] lv_child = (ListView)findViewById(R.id.lv_child); ArrayAdapter<String> adapterChild = new ArrayAdapter<String>(ChildActivity.this, android.R.layout.simple_list_item_1,array); lv_child.setAdapter

RecyclerView load more with ProgressBar error

我与影子孤独终老i 提交于 2019-12-02 06:42:22
问题 I'm trying to create Recyclerview onLoadMore with ProgressBar at the bottom. I've tried this solution, but method onLoadMore in my Activity is never called. Please, help me. Here is my Adapter : public class NewsAdapterTest extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private ArrayList<NewsDataModel> dataSet; private Context context; private final int VIEW_ITEM = 1; private final int VIEW_PROG = 0; // The minimum amount of items to have below your current scroll position before

Inflate ListView with TreeMap data (Custom Adapter)

安稳与你 提交于 2019-12-02 06:23:02
问题 Solved : I have created an adapter based on @JJV 's suggestion. I am aware that there is plenty of room for improvement, but it works for now. I have updated this simplified version of my program, with the working code; I hope it will be useful to others: MainActivity.java: import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ListAdapter; import android.widget.ListView; import java.util.Map; import java.util.TreeMap; public class MainActivity

How can I Reuse Methods for ListViews?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 06:12:53
I have several methods in the ListAC ListActivity that I want to reuse and would like to put in separate classes (if possible??). I will be having dozens of ListView Activities (ListActivities ie: ListAD, ListTCDS, listSFAR, etc., etc.) that will call on these methods that are exactly the same in this activity but the only changes in the 'Cursor databaseCursor' (ie. The Table name for each ListActivity). I plan on putting these Classes and related into their own packages w/n the application (ie: com.myCompany.myApp.AC) Also, w/n these Activities there needs to be multiple coursers for the

ScrollView嵌套ListView的问题同样适用于gridview

好久不见. 提交于 2019-12-02 05:49:43
以下文章转自 @安卓泡面 在工作中,曾多次碰到ScrollView嵌套ListView的问题,网上的解决方法有很多种,但是杂而不全。我试过很多种方法,它们各有利弊。 在这里我将会从使用ScrollView嵌套ListView结构的原因、这个结构碰到的问题、几种解决方案和优缺点比较,这4个方面来为大家阐述、分析、总结。 实际上不光是ListView,其他继承自AbsListView的类也适用,包括ExpandableListView、GridView等等,为了方便说明,以下均用ListView来代表。 一、 为什么要使用ScrollView嵌套ListView的奇怪的结构 ScrollView和ListView都是滚动结构,按理说,这两个控件在UI上的功能是一样的,但是看看下面这个设计: 这是天猫商城的确认订单的页面,ScrollView中嵌套了ExpandableListView,ExpandableListView上面有固定的一些控件,下面也有固定的一些控件,整体又要能够滚动。 列表数据要嵌在固定数据中间,并且作为整体一起滚动,有了这样的设计需求,于是就有了ScrollView嵌套ListView的奇怪结构。 二、 ScrollView、ListView嵌套结构碰到的问题 不多说,直接看失败例子: <ScrollView android:id="@+id/act_solution

RecyclerView load more with ProgressBar error

限于喜欢 提交于 2019-12-02 04:38:34
I'm trying to create Recyclerview onLoadMore with ProgressBar at the bottom. I've tried this solution , but method onLoadMore in my Activity is never called. Please, help me. Here is my Adapter : public class NewsAdapterTest extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private ArrayList<NewsDataModel> dataSet; private Context context; private final int VIEW_ITEM = 1; private final int VIEW_PROG = 0; // The minimum amount of items to have below your current scroll position before loading more. private int visibleThreshold = 2; private int lastVisibleItem, totalItemCount; private