android-listview

Getting NullPointerException in custom ListView

試著忘記壹切 提交于 2020-01-24 07:32:00
问题 I'm getting errors like this when I run my app: 02-27 22:59:19.331: E/AndroidRuntime(2060): FATAL EXCEPTION: main 02-27 22:59:19.331: E/AndroidRuntime(2060): java.lang.NullPointerException 02-27 22:59:19.331: E/AndroidRuntime(2060): at myPlanAdapter.getView(MyPlanActivity.java:145) 02-27 22:59:19.331: E/AndroidRuntime(2060): at android.widget.AbsListView.obtainView(AbsListView.java:1315) 02-27 22:59:19.331: E/AndroidRuntime(2060): at android.widget.ListView.measureHeightOfChildren(ListView

ClassCastException cannot convert LinearLayout$LayoutParams to AbsListView$LayoutParams when setting ListView Header

谁说胖子不能爱 提交于 2020-01-24 06:35:18
问题 First off, I've already figured out how to solve this bug, but at this point I'm just wondering why my fix works. The situation I was running into was that I was getting a ClassCastException, cannot convert LinearLayout$LayoutParams to AbsListView$LayoutParams when I tried to do the following (simplified for these purposes): mLayout = (LinearLayout) getLayoutInflater() .inflate(R.layout.my_header_layout, getListView(), false); mRootView.addView(mLayout); getListView().addHeaderView(mLayout);

Android: ListFragment get clicked item within ListItem

喜你入骨 提交于 2020-01-24 01:54:45
问题 My app contains 3 tabs.All the tabs contains List so I have used ListFragment. There is a button in each ListItem. I want to do " something " when " Click " button is clicked within the ListItem as shown in the figure. How do I implement this. There are tuts about doing same thing for ListActivity but not ListFragment .Thanks in advance. :) 回答1: First of all, you need to implement a custom adapter for your ListView. Please, read this article if you are not familiar with this. Next, you have

PinnedHeaderListView Example

旧街凉风 提交于 2020-01-23 12:03:49
问题 I want to implement a listview with section headers similar to the one found in android mobile contacts, in which the section headers do not scroll while scrolling the contents inside the header. I found out that something like a PinnedHeaderListView has to be implemented. Does anybody have ant example on how to develop a PinnedHeaderListView ? 回答1: Check out this Project using SVN from this link PinnedHeaderListView You will get sample App , inside that Click on Speakers there you can see

How to handle ListView Item LongPress gesture

瘦欲@ 提交于 2020-01-23 11:52:53
问题 i have small issues in event handling , i have List view custom adapter data , each row having date , title , price . when i click on row i need to display details page but when i long press on price , date or title i need to sort the list view. i need to use gesture for on Long Press. please refer below code what i have tried. Custom Adapter View public EventAdapterView(Context context, List<EventUtil> eventList) { this.mContext = context; this.mEventUtil = eventList; mLayoutInflater =

Delete item on ListView after click delete button on ListView

不想你离开。 提交于 2020-01-23 11:18:43
问题 I wrote a code to display images, button & texts dynamically in a ListView. So ListView load the button. I want to delete the selected item in ListView by clicking this button. Adapter class: public class LazyAdapter extends BaseAdapter { private Activity activity; private String[] data; private static LayoutInflater inflater=null; public ImageLoaderLogoUnder imageLoader; public LazyAdapter(Activity a, String[] d) { activity = a; data=d; inflater = (LayoutInflater)activity.getSystemService

how to change text size of listview

做~自己de王妃 提交于 2020-01-23 06:38:25
问题 I am using List Activity to retrieve data from SQLITE. But I can not set the font size of list view. Please help me. public class CartList extends ListActivity { private ArrayList<String> results = new ArrayList<String>(); public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(com.example.easyshopping.R.layout.cart); openAndQueryDatabase(); displayResultList(); } private void displayResultList() { setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list

How to remain the listView index selected and highlighted?

我们两清 提交于 2020-01-23 04:23:16
问题 In My app i have implement the ListView . Now i want it to set as like that: If i select on perticular index it should be remain as selected. ans appear as selected on ListView . If i select another index then now that new index should be remain as selected. Edited Means I want to set as the selected index should remain as highlighted as selected till I select another. but not like multiple selected. So how to do it ? Please help me for that. I have implemented the ListView as like below code

Swipe Gesture inside ListView - Android [closed]

别等时光非礼了梦想. 提交于 2020-01-22 16:49:26
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I am a newbie for Android. I got a tutorial on how to implement the `listView here: I implemented it and it is working fine. I need to implement a ViewSwitcher for the same. Like when I swipe the song, I need to

How to refresh list of the navigation drawer as soon as its open/closed in Android

蓝咒 提交于 2020-01-22 13:44:27
问题 I have created navigation drawer and displaying items in list. My list is static but i am displaying points. So when users select the items in the list and do some activity he get the points. So i want to update the points as soon as he gets. How can i do this./ Below is my code: Activity Class: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_page); // Initializing dataList = new ArrayList<DrawerItem>(); mTitle =