android-listview

Context menu for blank space in a listview

橙三吉。 提交于 2019-12-02 12:16:38
I have a simple LinearLayout with ListView inside it ( match_parent both for width and height). I need a context menu to show up upon a long touch on ANY place in the ListView. First, I called registerForContextMenu for the ListView. This makes the context menu show up ONLY if the touch is performed on a list item. Then I called registerForContextMenu for the LinearLayout as well, and set it attribute android:longClickable="true" . This did not help. So the question is how can one produce a context menu for a long touch below list items? For example, if we have 1 item in the list view, there

help with listview and R.layout.main (Android)

青春壹個敷衍的年華 提交于 2019-12-02 12:14:25
im quite new to android, so i apologise if this is a noob-ish question (: i designed my list following the example found here: http://android-er.blogspot.com/2010/06/custom-arrayadapter-with-with-different.html but what i would like to know is how would i go about adding setContentView(R.layout.main) so that i can display other (xml) elements along with the list? thanks for any advice (: You just edit your main.xml to look whatever you want it to look, eg: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

Show TextView for an empty ListView inside a FrameLayout

戏子无情 提交于 2019-12-02 11:53:16
I have a tabbed layout and an activity using tabs as views. It has three tabs as ListViews . If either of the lists is empty I want to show a simple TextView instead. I've gone through many posts but all of them talk about a single ListView inside a LinearLayout . I'm not sure if it is not working because of multiple ListViews or FrameLayout . Can we not set visibility = GONE inside a FrameLayout ? Because even then the TextView is always shown along with the ListView . Can anyone suggest what can be done in this scenario? I also tried including TextView in another xml file. But I'm not sure

ListView OnItemClickListener is not listening

巧了我就是萌 提交于 2019-12-02 11:39:06
I checked all the previous questions regarding this issue , but none of them are helpfull to me . My listview is not responding , i tried changing this list.setOnItemClickListener(new ContactsListItemClickListener(this)); to list.setOnItemClickListener(this); by making my PrioritiseContacts activity just imeplement OnItemClickListener , but then too its not working . The activity is successfully running , but i am unable to listen for listclick events. How to correct this? Here is my class : public class PrioritiseContacts extends Activity implements OnClickListener { private ListView list; //

ListView yielding nullpointerexception on setOnItemClickListener

断了今生、忘了曾经 提交于 2019-12-02 11:25:33
问题 I'm attempting to work with through some tutorial code and add in an OnItemClick Listener, but keep throwing an exception when it hits the listener and crashing my app. This is my first attempt at working in the Android environment, so I'm trying to learn how all these things are interrelated. Here's what I've tried: import java.util.ArrayList; import java.util.List; import org.json.JSONObject; import android.app.AlertDialog; import android.app.ListActivity; import android.os.Bundle; import

Best way to build and handle List view with differing rows

懵懂的女人 提交于 2019-12-02 11:23:29
In my app, I show data in a list view. It looks as below. Each row in list view is different (ie., they have a different view structure). But every row is made up of 1 to many subviews (all subview are same ). Problem: If try to inflate the rows from xml then I need to have xml with 1. 2 subviews 2. 3 subviews 3. 5 subviews and so on If I try to build the rows dynamically then I wont be able to take advantage of the holder pattern or the views re-usability of Listview. And I will end up building the subviews if the number of subviews, in the returned view is less than required or deleting in

Need help creating a list of YouTube Videos

拈花ヽ惹草 提交于 2019-12-02 11:15:26
I want to access Youtube videos and display the thumbnail of the video along with its title in a ListView. On clicking of the thumbnail, the video should be played. Can anyone suggest some sample program related to my need or link. Here my code for playing you-tube Video using Urls. This may not provide the complete requirement of yours but you can make use of it. My VideoPlayActivity.class (Activity) import java.io.File; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences.Editor; import android.media

How can I download ListView HTML images asynchronously?

ぐ巨炮叔叔 提交于 2019-12-02 11:05:36
As a prototype, I'm trying to modify the android-imagedownloader demo from the Android Developers Blog to work with HTML image tags rather than hard-coded ImageViews . I've modified it by replacing ImageAdapter.getView() with the following: public View getView(final int position, View view, final ViewGroup parent) { TextView textView = (TextView) view; if (textView == null) { textView = new TextView(parent.getContext()); textView.setPadding(6, 6, 6, 6); } textView.setText(Html.fromHtml("<img src=\"" + URLS[position] + "\"/>", new ImageGetter() { @Override public Drawable getDrawable(final

Android - ListViews inside tableLayout

╄→尐↘猪︶ㄣ 提交于 2019-12-02 11:02:33
I'm trying to build and app that shows organized data so I'm thinking that basically a TableLayout would be a good idea, just to keep them in rows, so I'm wondering whats the correct way to do it? I have this in my xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TableLayout android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TableRow> <TextView android:layout_width="fill

ListView.hasWindowFocus==true but child views hasWindowFocus==false

你。 提交于 2019-12-02 10:50:46
Sometimes I notice that, for a View v - v.hasWindowFocus()==false - ((View)v.getParent()).hasWindowFocus())==true If I understand the docs correctly, this should never be the case. v.getParent() is a (subclass) of ListView Any ideas on what might be causing this? Note: I assume this hasWindowFocus-mismatch is the root cause for this issue The main reason is that ListView doesn't like an adapter having an array of views. So the problem is triggered by code like public View getView (int position, View convertView, ViewGroup parent) { return _views[position]; } When looking at the ListView code