Tag: listview

Android隐藏的ListView滚动条?

有没有一种方法来隐藏ListView滚动条。 我知道这是可能的ScrollView但无法findListView滚动条的方式。 有任何想法吗?

ListView为空时显示空视图

出于某种原因,在这种情况下,即使ListView不为空,也会出现空视图,即TextView 。 我以为ListView会自动检测何时显示空的视图。 <RelativeLayout android:id="@+id/LinearLayoutAR" android:layout_height="fill_parent" android:layout_width="fill_parent"> <ListView android:id="@+id/ARListView" android:layout_width="fill_parent" android:layout_height="fill_parent"></ListView> <ProgressBar android:id="@+id/arProgressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true"></ProgressBar> <!– Here is the view to show if the list is emtpy –> <TextView android:id="@id/android:empty" android:layout_width="match_parent" android:layout_height="match_parent" android:text="No Results" /> </RelativeLayout> 我怎样才能正确地连接空视图?

Android,ListView IllegalStateException:“适配器的内容已经改变,但ListView没有收到通知”

我想要做的是 :运行后台线程,计算ListView内容并部分更新ListView,同时计算结果。 我知道我必须避免 :我不能混淆来自后台线程的ListAdapter内容,所以我inheritance了AsyncTask并从onProgressUpdate发布结果(将条目添加到适配器)。 我的适配器使用结果对象的ArrayList,这些数组列表上的所有操作都是同步的。 其他人的研究 :这里有非常有价值的数据。 我也遇到了几乎每天大约500人的崩溃,当我在onProgressUpdate中添加list.setVisibility(GONE)/trackList.setVisibility(VISIBLE)块时,崩溃降低了10倍,但没有消失。 (有人build议回答 ) 我有时得到的是 :请注意,这真的很less发生(一个3.5k用户每周一次)。 但是我想彻底摆脱这个错误。 这里是部分堆栈跟踪: `java.lang.IllegalStateException:` The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2131296334, class android.widget.ListView) with Adapter(class […]

ArrayIndexOutOfBoundsException自定义Android适配器在ListView中的多个视图

我试图为我的ListView创build一个自定义的适配器,因为列表中的每个项目可以有不同的视图(链接,切换或广播组),但是当我尝试运行使用ListView的活动时,我收到一个错误该应用程序停止。 该应用程序是针对Android 1.6平台的。 代码: public class MenuListAdapter extends BaseAdapter { private static final String LOG_KEY = MenuListAdapter.class.getSimpleName(); protected List<MenuItem> list; protected Context ctx; protected LayoutInflater inflater; public MenuListAdapter(Context context, List<MenuItem> objects) { this.list = objects; this.ctx = context; this.inflater = (LayoutInflater)this.ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public View getView(int position, View convertView, ViewGroup parent) { Log.i(LOG_KEY, "Position: " […]

如何将baselineAligned设置为false来提高LinearLayout的性能?

我只是在xml中创build了一些UI,而Lint给了我一个警告,并说要设置android:baselineAligned为false来提高ListView的性能。 添加此警告的Lint更改的文档说 布局性能:查找带有权重的LinearLayouts,您应该在其中设置android:baselineAligned =“false”以获得更好的性能,并且还会发现嵌套权重可能导致性能问题的情况。 有人可以解释为什么这会提高性能,特别是当涉及重量?

如何获得布局Inflater给定一个上下文?

我正在编写一个ListAdapter的自定义实现。 在它的构造函数中,我正在使用一个Context,一个资源ID(即表示布局文件的R.id.xxx)以及一个列表和一个映射(它们包含数据)。 现在,问题是,我将需要一个LayoutInflater来获取在单独的布局XML文件中的视图对象。 我怎样才能得到只给定上下文的LayoutInflater? 现在,为什么我认为这是可能的,这是非常相似的传递给ArrayAdapter(上下文,资源,textViewResourceId,数据数组)的构造函数,我想ArrayAdapter也必须利用LayoutInflater只给出一个Context。 但是怎么做呢?

如何animation添加或删除Android ListView行

在iOS中,有一个非常简单而强大的工具来animation添加和删除UITableView行, 这里是一个来自YouTubevideo的剪辑,显示了默认的animation。 请注意周围的行如何折叠到删除的行上。 这个animation可以帮助用户跟踪列表中更改的内容以及数据更改时他们正在查看的列表中的哪些内容。 由于我一直在Android上开发,我没有find相应的工具来animationTableView中的单个行。 在适配器上调用notifyDataSetChanged()会导致ListView立即使用新信息更新其内容。 我想展示一个简单的animation,当数据改变时,推入或滑出的新行,但我找不到任何logging的方式来做到这一点。 它看起来像LayoutAnimationController可能持有一个关键,让这个工作,但是当我在我的ListView上设置一个LayoutAnimationController(类似于ApiDemo的LayoutAnimation2 ),并在列表显示后从我的适配器中删除元素,元素立即消失,而不是animation。 我也尝试了下面这样的事情来移动一个单独的项目, @Override protected void onListItemClick(ListView l, View v, final int position, long id) { Animation animation = new ScaleAnimation(1, 1, 1, 0); animation.setDuration(100); getListView().getChildAt(position).startAnimation(animation); l.postDelayed(new Runnable() { public void run() { mStringList.remove(position); mAdapter.notifyDataSetChanged(); } }, 100); } 但是,在调用notifyDataSetChanged()时,围绕animation行的行不会移动位置,直到它们跳到新的位置。 看来ListView一旦放置了元素就不会更新其布局。 虽然写我自己的实施/叉的ListView已经跨越了我的脑海,这似乎是不应该那么难。 谢谢!

Listview更新列表后滚动到列表的末尾

我想确保列表滚动到底部,我已经使用listAdapter更新列表视图,以便它显示列表中input的最后一个元素。 我怎样才能做到这一点 ? 我尝试过,但没有运气: lv.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL); 谢谢

列表视图getListItemXmlAttributes方法失败,并具有子发布项目

我已经创build了一个JS类来填充SG /文件夹列表视图数据,当项目被修改。 ( 按照Jaime的方法)当我操作创build出版物中的项目时,一切都很好。 例如:我打开一个组件或页面, locked by列locked by的自定义立即更新并显示我的用户名。 然而,当我去一个儿童出版物,并重复这个过程,我得到的窗口,问我是否要本地化或编辑父项。 如果我select编辑父窗口,代码不起作用。 我还没有完全想到它与初步debugging。 Chrome似乎吞噬了这个错误,Firefox给了我一个神秘的: 时间戳:6/22/2012 3:42:54 PM 错误:未捕获exception:[exception…]组件返回失败代码:0x80004002(NS_NOINTERFACE)[nsIWebProgress.DOMWindow]“nsresult:”0x80004002(NS_NOINTERFACE)“位置:”JS框架:: chrome:// browser / content / tabbrowser .xml :: :: line 545“data:no] 有没有人有任何初步的想法? 我会尽量后来发布一些代码… 来自PageEx.js的代码: Type.registerNamespace("MyCompany.Tridion.RTFExtensions"); /* * Constructor */ MyCompany.Tridion.RTFExtensions.PageEx = function (id) { Type.enableInterface(this, "MyCompany.Tridion.RTFExtensions.PageEx"); this.addInterface("Tridion.ContentManager.Page", [id]); var p = this.properties; p.versionNumberString = undefined; p.modifiedBy = undefined; p.lockedBy […]

Android系统。 一起滚动2个列表视图

好。 我想要实现的是一个布局,与Excel中的冻结窗格的效果相同。 那是我想要一个水平滚动与主ListView和一个左侧ListView垂直滚动与主ListView的标题行。 在其他维度中滚动时,标题行和左侧列表视图应保持静止。 这里是xml布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/recordViewLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <LinearLayout android:layout_width="160dp" android:layout_height="match_parent" android:orientation="vertical"> <CheckBox android:id="@+id/checkBoxTop" android:text="Check All" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ListView android:id="@+id/engNameList" android:layout_width="160dp" android:layout_height="wrap_content"/> </LinearLayout> <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/scroll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <include layout="@layout/record_view_line" android:id="@+id/titleLine" /> <ListView android:id="@android:id/list" android:layout_height="wrap_content" android:layout_width="match_parent"/> </LinearLayout> </HorizontalScrollView> </LinearLayout> 我然后在ListActivity中使用这个代码 public void onScroll(AbsListView view, int […]