<?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" >
<include
android:id="@+id/action_bar_detail"
layout="@layout/action_bar" />
<RelativeLayout
android:id="@+id/linlay_reply"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:focusable="true"
android:focusableInTouchMode="true" >
<Button
android:id="@+id/btn_detail_reply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/reply" />
<EditText
android:id="@+id/et_reply_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/btn_detail_reply"
android:inputType="text"
android:labelFor="@id/et_reply_content" />
</RelativeLayout>
<ListView
android:id="@+id/lv_passage_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/linlay_reply"
android:layout_below="@id/action_bar_detail"
android:layout_marginTop="2dp"
android:dividerHeight="2dp" />
</RelativeLayout>
在fininshing输入edittext中的某些内容后关闭软键盘。
根据logcat,它会导致如下错误 昨天是“MessageQueue-JNI” 今天早上是“停止没有恢复的活动。”
我很困惑。任何人都能搞清楚吗?
04-11 14:49:10.032: E/libEGL(5593): call to OpenGL ES API with no current context (logged once per thread)
04-11 14:49:15.813: E/AndroidRuntime(5593): Process: com.example.simplebbs, PID: 5593
04-11 14:49:15.813: E/AndroidRuntime(5593): java.lang.NullPointerException
04-11 14:49:15.813: E/AndroidRuntime(5593): at simplebbs.example.adapter.PassageDetailAdapter.getView(PassageDetailAdapter.java:74)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.AbsListView.obtainView(AbsListView.java:2324)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.ListView.makeAndAddView(ListView.java:1812)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.ListView.fillDown(ListView.java:698)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.ListView.fillSpecific(ListView.java:1359)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.ListView.layoutChildren(ListView.java:1623)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.AbsListView.onLayout(AbsListView.java:2173)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.View.layout(View.java:15128)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.ViewGroup.layout(ViewGroup.java:4867)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1160)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.View.layout(View.java:15128)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.ViewGroup.layout(ViewGroup.java:4867)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.View.layout(View.java:15128)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.ViewGroup.layout(ViewGroup.java:4867)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.View.layout(View.java:15128)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.ViewGroup.layout(ViewGroup.java:4867)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.View.layout(View.java:15128)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.ViewGroup.layout(ViewGroup.java:4867)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2321)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2027)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1193)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6230)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.Choreographer.doCallbacks(Choreographer.java:591)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.Choreographer.doFrame(Choreographer.java:560)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.os.Handler.handleCallback(Handler.java:808)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.os.Handler.dispatchMessage(Handler.java:103)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.os.Looper.loop(Looper.java:193)
04-11 14:49:15.813: E/AndroidRuntime(5593): at android.app.ActivityThread.main(ActivityThread.java:5390)
04-11 14:49:15.813: E/AndroidRuntime(5593): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 14:49:15.813: E/AndroidRuntime(5593): at java.lang.reflect.Method.invoke(Method.java:515)
04-11 14:49:15.813: E/AndroidRuntime(5593): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:851)
04-11 14:49:15.813: E/AndroidRuntime(5593): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:667)
04-11 14:49:15.813: E/AndroidRuntime(5593): at dalvik.system.NativeStart.main(Native Method)
现在不一样了。 当我将edittext的可见性设置为不见时。错误也消失了。
if (mComments.size() != 0 && position != 0) {
detailHolder.replyContent.setText(mComments.get(position - 1)
.getReplyContent());
detailHolder.replytime.setText(mComments.get(position - 1)
.getReplyTime());
detailHolder.replyUserName.setText(mComments.get(position - 1)
.getReplyUserName());
}
这是logcat所说的错误位置。
答案 0 :(得分:0)
您的编辑框和列表视图之间应该没有任何关系。如果您正在尝试获取用户输入并希望在listview中填充,则可能会出现一些问题。 你的logcat说它是一个nullpointer异常。表示您尝试加载数据的textview为null或对象(mComment)为null。
答案 1 :(得分:0)
我仍然无法在没有代码的情况下为你的listview adapter
做出太多贡献,所以我做了一些看起来像你布局的内容,让我知道,你对listview adapter
有什么改变
比RelativeLayout
更独立,因此您不应该遇到此问题layout
代码
private ListView listView;
private ArrayAdapter<String> adapter;
private String[] menu = { "Example1", "Example1", "Example1", "Example1",
"Example1", "Example1", "Example1", "Example1", "Example1",
"Example1", "Example1" };
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.listview_activity);
listView = (ListView)findViewById(R.id.lv_passage_detail);
adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, menu);
listView.setAdapter(adapter);
}
listview_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="4dp"
android:background="#eef">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#efe"
android:weightSum="100"
android:layout_margin="4dp">
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button"
android:layout_weight="70"/>
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ems="10"
android:layout_weight="30">
<requestFocus />
</EditText>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/lv_passage_detail"
android:padding="2dp"
android:layout_margin="4dp"
android:background="#959"
/>