android-listview

Grabbing the list item TextView value when ContextMenu is opened

给你一囗甜甜゛ 提交于 2019-12-13 01:43:23
问题 On a ListView single/short click, I can do this: protected void onListItemClick(ListView listView, View v, int position, long id) { tvInt = reviews.get(position); } How would I do this for a ContextMenu ? My ListView simply contains a single TextView . Edit: I want to grab the value of the TextView in the ListView , not the ContextMenu . 回答1: The MenuItem packs extra information from where you could extract the position of the clicked row in the ListView and then simply use the code you used

How do you change the background color of a TextView that is inside a ListView Programmatically?

試著忘記壹切 提交于 2019-12-13 01:29:39
问题 I have a ListView that contains several TextView items. This list is created at runtime, and can vary in size. I would like to set the background of a TextView item based on a float value generated at runtime. I am using an ArrayAdapter. setListAdapter(new ArrayAdapter<String>(this, R.layout.list_fruit,ratios)); final ListView listView = getListView(); listView.setTextFilterEnabled(true); listView.setBackgroundColor(Color.LTGRAY); ((TextView) listView.getChildAt(0)).setBackgroundColor(Color

Custom Dates in Android ListView (Java Formatting)

ぐ巨炮叔叔 提交于 2019-12-13 01:28:05
问题 I have a ListView that users will put comment in. When they hit "submit" attached to an EditText box, the new comment goes into a MySQL database along with the current time. I'd like the comments to appear in the listview with dates similar to Youtube formatting. For example: "10 seconds ago", "1 day ago", "52 days ago". Would I use the Calendar object, SimpleDateFormat, something else? Also, how would I store the date in the datebase? I am assuming something easily convertible like the UNIX

Null Pointer Exception in LayoutInflator

老子叫甜甜 提交于 2019-12-13 01:14:27
问题 I am getting a Null Pointer Exception at LayoutInflator in my ExpandListAdapter class that extends BaseExpandableListAdaptor. import java.util.ArrayList; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import android.widget.TextView; public class ExpandListAdapter extends BaseExpandableListAdapter{ private Context context; private ArrayList<ExpandListGroup> groups;

How to run the query of a FilterQueryProvider asynchronously?

北城余情 提交于 2019-12-13 00:55:55
问题 I'm using a FilterQueryProvider to filter the content of a list view which is backed up by a custom CursorAdapter. To use the FilterQueryProvider you have to override the runQuery() method which returns a Cursor object. Now I'm wondering how to query for the cursor asynchronously to avoid blocking the UI thread. Is there some kind of best practice? I couldn't find any information whether the the runQuery() method is executed on the UI-thread or on its own thread. 回答1: From the documentation :

How to highlight android listview first item after load items to listview?

人走茶凉 提交于 2019-12-13 00:41:03
问题 1.This is my listview <ListView android:id="@+id/lv_FromTable" android:layout_width="match_parent" android:layout_height="match_parent" android:choiceMode="singleChoice" android:listSelector="@drawable/list_selector" android:orientation="vertical" /> 2.in onCreate of main activity i load item and set adapter to listview lv_FromTable = (ListView)rootView.findViewById(R.id.lv_FromTable); FromTableAdapter = new ManageTableAdapter(context, FromTableList); lv_FromTable.setAdapter(FromTableAdapter)

Got threadid=1: thread exiting with uncaught exception (group=0x41088930) on listview

南楼画角 提交于 2019-12-12 23:20:00
问题 i'm making an app that shows running apps icon on listview. there are no syntax problem (i think) but when i launch app and try to run activity, the app force closes and i got threadid=1: thread exiting with uncaught exception (group=0x41088930) and more error how can i fix this error? should i use Asynctask to load image to list view? or any solutions? (Logcat) 02-18 14:17:46.700: W/dalvikvm(18370): threadid=1: thread exiting with uncaught exception (group=0x41088930) 02-18 14:17:46.700: E

Send data from edittext to listview

拜拜、爱过 提交于 2019-12-12 21:30:11
问题 I have created two Activities ( MainActivity , ListActivity ) and in MainActivity , I have an EditText and a save-button. In ListActivity , I have a ListView . I want to save the value/data/string text that is written in EditText and send it to the other Activity in the ListView . This is how it looks now, but I think I know what I'm missing but don't know how to do it. MainActivity. public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) {

How to store items of multiple JSON Array and display it listview?

谁说胖子不能爱 提交于 2019-12-12 19:33:14
问题 In my application I am using listview and I am also doing json parsing. Now the issue is I want to set colors in my views, the color code I am getting from server. Following is my json response and java code can any one help me, to set color codes in my views? [ { "id_product": "1445", "name": "Stylish Sleeveless Leather Vest", "price": 1990, "discount": 199, "colors": [ "#000000", "#7E3517", "#C85A17" ], "sizes": [ "Medium", "Large", "Small" ], "img_url": "", "popup_images": [ ] }, { "id

How to add a Footer View (TextView) to the end of a ListView?

徘徊边缘 提交于 2019-12-12 19:19:17
问题 i am trying to make a layout like this: actionbar ==================== txtViewTitle -------------------- listview item1 listview item2 listview item3 ........scroll scroll scroll ...at the end of all the items: ----------------- txtViewFooter ================== linearlayout of buttons [always visible at the bottom] ------------------------------- the part between the ==========s should be scrollable here's my code, it works except for txtViewFooter which is displayed if the list is short