Tag: android listview

使用幻灯片删除项目列表视图 – 与Gmail一样

我正在开发一个列表视图中的商店列表的应用程序。 我需要当我滑动listview的项目向右(或左),这个项目应该从列表视图中删除。 我有我的列表视图,只需要执行它的function。 提前致谢。

当用户旋转手机并保留ArrayAdapter中的所有数据时,保留列表视图项的好scheme

我使用listView的片段。 我通过自定义加载程序(从Internet)接收的数据填充与此列表视图关联的ArrayAdapter。 自定义ArrayAdapter支持无限滚动(分页)。 当用户旋转设备并在ListView中保持滚动位置时,在ArrayAdapter中存储项目的最佳方式是什么? 我正在考虑用ArrayAdapter创build非可视化片段,并使用setRetainInstance方法来保存值。 任何build议更好的解决scheme?

自定义列表视图上的选定项目与上下文操作栏

我最近开始使用android 操作栏和上下文操作栏 (CAB)。 我只有一个活动,这是一个ListActivity。 基本上我使用下面的代码来“激活”CAB: ListView listView = getListView(); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Here you can do something when items are selected/de-selected, // such as update the title in the CAB } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond […]

如何从多选列表视图中select项目

我正在使用一个数组适配器,并为此添加一个strings的数组列表,列表是多select,我怎样才能得到点击列表项的值? my_contacts_list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice,conts_list); my_contacts_list.setAdapter(adapter); 我正在努力做到这一点, SparseBooleanArray positions = my_contacts_list.getCheckedItemPositions(); int size=positions.size(); int i=0; while(i <= size){ conts_list.get(positions.get(i)); i++; } 但是position.get(i)是一个数组列表,那么如何检索选中的项呢?

MotionEvent.ACTION_UP未被调用

请考虑休耕(为了更好地理解我的问题)。 正如你所看到的,我正在考虑一个由填充包围的列表视图。 现在,如果用户按下列表视图项目,作为我已经提供了浅蓝色背景颜色的行动。 现在,我的应用程序正在处理onTouch事件本身来确定类似的操作 点击 从左到右滑动 从右到左滑动 这是我的代码。 public boolean onTouch(View v, MotionEvent event) { if(v == null) { mSwipeDetected = Action.None; return false; } switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: { downX = event.getRawX(); downY = event.getRawY(); mSwipeDetected = Action.Start; // Find the child view that was touched (perform a hit test) Rect rect = […]

如何在android中使用快速滚动?

我有一个按月份和年份分列的事件列表(2010年6月,2010年7月等) 我想启用快速滚动,因为列表很长。 如何在Android的ListViews上启用快速滚动?

如何实现“刷新刷新”就像在新的GMail应用程序

谷歌发布新的Gmail应用程序,以处理下拉刷新的替代方式。 而不是显示开始隐藏的行被拉下来。 Gmail会在操作栏上方显示animation消息。 该消息包含一条animation水平线。 这是Android SDK的标准function吗? 我无法find任何可以做到这一点的操作栏API。

在接收gcm推送通知时刷新活动

如果我的应用程序处于打开状态,如何刷新 接收gcm推送通知的活动。 我有一个活动,其中包含从服务器填充数据的列表视图。 如果我收到gcm推送通知(也包含一些数据),我想刷新我的活动( 这里再添加一个项目到列表视图 )。 一种替代方法是添加定时器 ,定期做服务器请求和更新列表适配器数据,但我不想要这些,因为它会花费很多资源。 我是否需要添加广播接收器 ,这将触发接收gcm推进哪些进一步请求更新的服务器数据和更新我的活动用户界面? 亲爱的评论者,请仔细阅读这个问题,我只需要刷新列表 (如果应用程序是打开的,特定的活动是开放的), 否则不需要相同的 。

在运行时android如何使文本的一部分粗体?

在我的应用程序中有一个ListView有许多string元素,如name , experience , date of joining等。我只是想让name加粗。 所有的string元素将在一个单一的TextView 。 我的XML: <ImageView android:id="@+id/logo" android:layout_width="55dp" android:layout_height="55dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="15dp" > </ImageView> <TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/logo" android:padding="5dp" android:textSize="12dp" > </TextView> 我的代码来设置ListView项目的TextView: holder.text.setText(name + "\n" + expirience + " " + dateOfJoininf);

ListView的最后一项之后的分隔符(divider)

当我创build一个只有ListView的简单布局时,最后一个项目后面没有显示分隔符 ,这看起来有点难看。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" /> </RelativeLayout> 但是,我发现如果我添加另一个视图下面的列表视图,并设置列表视图的android:layout_above属性,最后一个项目后面显示分隔符。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/bottom" android:layout_alignParentTop="true" /> <TextView android:id="@+id/bottom" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="@android:color/holo_blue_dark" android:text="Bottom" /> </RelativeLayout> 为什么列表视图像这样? 我怎样才能得到一个分隔符后,只包含一个列表视图的布局中的最后一个项目?