android-listview

Where should I place the onClickListener on a Custom ListView?

不想你离开。 提交于 2019-12-03 16:27:06
I am making a custom ListView of rows containing a CheckBox and a TextView . Before I used custom ListViews with SimpleCursorAdapter, my onListItemClick() worked fine. I've read I have to add an onClickListener to my TextViews but WHERE? And WHY? I am still extending ListActivity and passing an Adapter to setListAdapter(listedPuzzleAdapter); , am I not? public class PuzzleListActivity extends ListActivity { private PuzzlesDbAdapter mDbHelper; private Cursor puzzlesCursor; private ArrayList<ListedPuzzle> listedPuzzles = null; private ListedPuzzleAdapter listedPuzzleAdapter; private class

Android's RelativeLayout seems broken

送分小仙女□ 提交于 2019-12-03 16:21:08
问题 I'm working on a layout where I use a ListView with RelativeLayout line items. The lineitems themselves are not displaying correctly. The issue is that the txtVideoDuration TextView is drawn at the top of the line item instead of the bottom. Because of this the txtVideoTitle gets a height of 0. As you can see in the XML the txtVideoDuration is supposed to be clamped to the bottom of the ListView. My goal is to have the layout resemble the tutorial that google gave me. Example: http://android

AdapterView.OnItemClickListener with more ListView

本小妞迷上赌 提交于 2019-12-03 16:08:22
I have 2 ListView on a single fragment and I wonder if I can set for both same class that implements AdapterView.OnItemClickListener. I mean, Android Documentation says: public abstract void onItemClick (AdapterView<?> parent, View view, int position, long id) Added in API level 1 Callback method to be invoked when an item in this AdapterView has been clicked. Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item. Parameters parent The AdapterView where the click happened. view The view within the AdapterView that was clicked (this

add background image to android ListView using Picasso

你离开我真会死。 提交于 2019-12-03 15:12:24
I need to add a background image to a ListView. Normally I would call listview.setBackground(myImage) . But the image is coming from server and so I need to use Picasso to load the image into the background of my ListView. How do I do that? Option One Define an anonymous subclass of com.squareup.picasso.Target Picasso.with(yourContext) .load(yourImageUri) .into(new Target() { @Override @TargetApi(16) public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { int sdk = android.os.Build.VERSION.SDK_INT; if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { yourListView

Enable/Disable item selection at listview in multiple choice mode

末鹿安然 提交于 2019-12-03 14:45:20
I have a listview registered for context menu in multiple choice mode: private void initListViewForContextMenu(){ log.d("FilesFragment", "initListViewForContextMenu()"); ListView listView = getListView(); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { ... The problem is that not all the items of my view should be selectable, only those showing a special icon should be available for selection. I don't know how to implement this, I've defined an OnItemLongClickListener : getListView().setOnItemLongClickListener(new

Android : getChild() EditText values on button click in ExpandableListView

耗尽温柔 提交于 2019-12-03 14:42:49
I'm developing Expandablelistview in Android. In the GroupView has only a title and every group has different ChildView. This code is working fine and i'm able to see different ChildView's in every Group item. In ChildView i have an EditText and when i click on done button i want to get all EditText and Spinner values which are inputs by user. When i click on done button at that time, i want to get details which is filled by user in Group items Customer Location etc. For a example : the image shown in question. I want to get the input details which is filled by user in vehicle and TEST group

How to set a simple adapter to listview?

落花浮王杯 提交于 2019-12-03 14:20:25
I have problem adding arraylist to list view, will explain about my problem here.. tell me what is wrong here... I have three linear layouts, and in the middle layout i have list view, as shown in the xml file below.. ` <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout

How to add dividers between disabled items in ListView? - Lollipop

爱⌒轻易说出口 提交于 2019-12-03 14:20:15
To add the dividers between disabled items (not clickable) in ListView for Android previous to Lollipop I override adapter's method areAllItemsEnabled() to return true. But now in Lollipop this method doesn't fix the problem. The dividers are invisible in ExpandableListView too. Is there a way to fix this problem without adding the divider in my item layout? 840Ci We ended up adding two Views of 1dp to fake the divider and checking on version to set Visibility. The problem is worse. We also needed to keep track of if the next row is enabled or not, if it is the last row. A lot of cheese on an

How to get checked radio button in list view?

a 夏天 提交于 2019-12-03 14:15:37
问题 I want to get checked radio button from list view from list item like below image. AttendanceView.class package com.cfms.ApplicationLayer; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.RadioGroup; import

Custom SimpleCursorAdapter, database query and NullPointerException

被刻印的时光 ゝ 提交于 2019-12-03 14:02:29
问题 I'm trying to make ListView populated from database, and spice each row with fancy delete button. So I made list Activity and custom SimpleCursorAdapter. This is main ListView activity: public class EditEntries extends ListActivity { Cursor cursor; DBAdapter db = new DBAdapter(this); private static String[] FROM = { _ID, SCORE_COLUMN, "date(time, 'localtime')", }; private static int[] TO = { R.id.rowid, R.id.title, R.id.time, }; public void onCreate(Bundle savedInstanceState) { super.onCreate