作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
美好的一天。我尝试使用 map View 和 ListView 创建 Activity 。我做了什么
public class EnrouteActivity extends MapActivity {
private ListView pointsListView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.enroute_work_layout);
this.pointsListView = (ListView)findViewById(R.id.listViewPoints);
String[] items = new String[] {"Пункт А", "Пункт Б", "Пункт В"};
//String[] items = this.GetAdapter();
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items);
this.pointsListView.setAdapter(adapter);
this.pointsListView.setItemsCanFocus(false);
this.pointsListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
private String[] GetAdapter(){
Routes routes = new Routes();
String[] items = new String[routes.points.size()];
for(int i = 0; i<routes.points.size(); i++){
items[i] = routes.points.get(i).name;
}
return items;
}
此布局的一部分
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2.81"
android:orientation="vertical" >
<CalendarView
android:id="@+id/calendar"
android:layout_width="360dp"
android:layout_height="234dp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Список точек по маршруту"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView
android:id="@+id/listViewPoints"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:choiceMode="multipleChoice" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="604dp"
android:layout_height="match_parent"
android:layout_above="@+id/linearLayout1"
android:layout_below="@+id/editText"
android:apiKey="0FLRiHvfPXL2mqzQihPemczCJMUjk3TTD8umAPw"
android:clickable="true"
android:enabled="true" />
</LinearLayout>
这里是异常(exception)
09-14 13:39:02.331: E/MapActivity(9606): Couldn't get connection factory client
09-14 13:39:02.464: D/dalvikvm(9606): GC_CONCURRENT freed 783K, 6% free 15328K/16199K, paused 2ms+3ms
09-14 13:39:02.464: E/System(9606): Uncaught exception thrown by finalizer
09-14 13:39:02.464: E/System(9606): java.lang.IllegalStateException: Binder has been finalized!
09-14 13:39:02.464: E/System(9606): at android.os.BinderProxy.transact(Native Method)
09-14 13:39:02.464: E/System(9606): at android.database.BulkCursorProxy.close(BulkCursorNative.java:288)
09-14 13:39:02.464: E/System(9606): at android.database.BulkCursorToCursorAdaptor.close(BulkCursorToCursorAdaptor.java:133)
09-14 13:39:02.464: E/System(9606): at android.database.CursorWrapper.close(CursorWrapper.java:49)
09-14 13:39:02.464: E/System(9606): at android.content.ContentResolver$CursorWrapperInner.close(ContentResolver.java:1591)
09-14 13:39:02.464: E/System(9606): at android.content.ContentResolver$CursorWrapperInner.finalize(ContentResolver.java:1604)
09-14 13:39:02.464: E/System(9606): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182)
09-14 13:39:02.464: E/System(9606): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
09-14 13:39:02.464: E/System(9606): at java.lang.Thread.run(Thread.java:856)
我找到了 this话题,但我不明白,他们说的是什么类(class) =((
最佳答案
09-14 13:39:02.464: E/System(9606): java.lang.IllegalStateException: Binder has been finalized
android.database.BulkCursorToCursorAdaptor.close(BulkCursorToCursorAdaptor.java:133)
您的游标适配器似乎在提交到 ListView 之前关闭了。仔细检查任何 close()
调用的代码。
关于java - Android 应用程序中的终结器抛出未捕获的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12425964/
据我所知,不能保证 Object.finalize() 总是被调用。但是如果有重要的非GC资源,并且用户没有意外调用close(),我该如何释放该资源?PS。 .NET中的Object.Finaliz
我是一名优秀的程序员,十分优秀!