Tag: listview

如何在Android中处理ListView点击

我如何聆听ListView上的单击事件? 这是我现在所拥有的 ListView list = (ListView)findViewById(R.id.ListView01); … list.setAdapter(adapter); 当我做以下 list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView parentView, View childView, int position, long id) { setDetail(position); } public void onNothingSelected(AdapterView parentView) { } }); 这似乎没有做任何事情点击。 所有这些代码都存在于扩展Activity的类中。

如何将Android Wifi扫描结果放入列表中?

我知道如何得到一个Android无线扫描,但我不知道最好的方式来制作一个列表适配器。 我想只是将SSID和BSSID从一次扫描绑定到text1和text2。 我一直在做的样品 wifi.startScan(); // get list of the results in object format ( like an array ) List<ScanResult> results = wifi.getScanResults();` // loop that goes through list for (ScanResult result : results) { Toast.makeText(this, result.SSID + " " + result.level, Toast.LENGTH_SHORT).show(); 和: private void fillDataFromDb() { Cursor scanCursor = Db.fetchAllScans(); startManagingCursor(scanCursor);` // Create an […]

Android ListView刷新单行

在获取ListView的单行数据后,我想更新该单行。 目前我正在使用notifyDataSetChanged(); 但是这使得View反应非常缓慢。 还有其他解决scheme吗?

Android:从数据库绑定数据到ListView中的checkbox?

我试图将数据从我的SQLiteDatabase绑定到一个ListView 。 我目前正在使用SimpleCursorAdapter来填充我的ListView 。 不幸的是,这似乎并没有设置CheckBox的检查属性。 我现在是这样做的; 不是更改CheckBox的检查状态,而是将适配器的值填充到text参数中,所以该值作为文本显示在CheckBox右侧。 Java的: setListAdapter( new SimpleCursorAdapter( this, R.layout.mylist, data, new String[] { Datenbank.DB_STATE, Datenbank.DB_NAME }, new int[] { R.id.list_checkbox, R.id.list_text } ) ); mylist.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" > <CheckBox android:text="" android:id="@+id/list_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" ></CheckBox> <TextView android:text="" android:id="@+id/list_text" android:layout_width="wrap_content" android:layout_height="wrap_content" ></TextView> </LinearLayout> 编辑:在数据库中的字段当然是布尔types,我也试图分配一个ID到选中的字段来填充的值。

使用自定义(对象)适配器筛选ListView

我试图实现过滤使用自定义对象适配器的ListView,但我找不到任何有用的示例。 包含的代码是非常简单的,所以不要记住我不能使用常规的ArrayAdapter。 我在ListView上面有一个EditText,并且当用户在EditText小部件中input文本时,我想通过EditText中写入的文本过滤ListView。 我们欢迎所有的build议! 以下是活动类的片段: public class management_objects extends Activity { private static List<User> UserList; private EfficientAdapter adapter = null; private ListView objectListView = null; private EditText SearchText = null; private static class EfficientAdapter extends BaseAdapter implements Filterable{ private LayoutInflater mInflater; public EfficientAdapter(Context context) { mInflater = LayoutInflater.from(context); } public int getCount() { return UserList.size(); […]

ListView的setOnItemClickListener不工作通过添加button

我有一个列表视图与文本和button在每一行,列表视图setOnItemClickListener()不工作。 是否有可能处理项目点击和button点击事件不同(项目点击应该调用ActivityA和button点击应该调用ActivityB)。 有没有人有解决scheme private ArrayList<String> userIDArr = null; private ArrayList<String> userNameArr = null; private DatabaseHelper dbHelper = null; private ListView userListView=null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_view); dbHelper = new DatabaseHelper(this.getApplicationContext()); Map<String,ArrayList<String>> displayMap = dbHelper.getUserListToDisplay(); userIDArr = displayMap.get("UserID"); userNameArr = displayMap.get("FirstName1"); userListView = (ListView) findViewById(R.id.listView2); userListView.setAdapter(new UserListAdapter(this,userIDArr)); userListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> […]

RecyclerView与ListView

从android开发者( 创build列表和卡片 ): RecyclerView小部件是ListView的更高级和灵活的版本。 好吧,这听起来很酷,但是当我看到这个示例图片时,我对这两者之间的区别感到困惑。 上面的图片可以通过带有自定义适配器的ListView轻松创build。 那么,在什么情况下应该使用RecyclerView ?

findViewById vs在ListView适配器中查看持有者模式

我总是使用LayoutInflater和findViewById在Adapter的getView方法中创build新项目。 但在许多文章中,人们写的findViewById是非常非常慢,强烈build议使用查看持有人模式。 任何人都可以解释为什么findViewById是如此之慢? 为什么查看模式更快? 如果需要将不同的项目添加到ListView我应该怎么做? 我应该为每种types创build类吗? static class ViewHolderItem1 { TextView textViewItem; } static class ViewHolderItem2 { Button btnViewItem; } static class ViewHolderItem3 { Button btnViewItem; ImageView imgViewItem; }

Android列表视图拖放sorting

我有一个listview中的logging列表,我希望用户能够使用拖放方法重新sorting。 我已经看到这在其他应用程序中实现,但我还没有find一个教程。 这一定是别人需要的东西。 任何人都可以指向我一些代码做这个?

Android ListView标题

我有ListView上有一些事件。 事件按datesorting,我想每天都有标题和date,然后事件在下面进行监听。 以下是我如何填充该列表: ArrayList<TwoText> crs = new ArrayList<TwoText>(); crs.add(new TwoText("This will be header", event.getDate())); for (Event event : events) { crs.add(new TwoText(event.getStartString() + "-" + event.getEndString(), event.getSubject())); } arrayAdapter = new TwoTextArrayAdapter(this, R.layout.my_list_item, crs); lv1.setAdapter(arrayAdapter); 这就是我的TwoText类的外观: public class TwoText { public String classID; public String state; public TwoText(String classID, String state) { this.classID = classID; […]