0

隠された値のような標準ビュー(imageview、imagebutton、textview、buttonなど)はありますか?したがって、各アイテムにこの値を設定してから、たとえば、onclickイベントのビューから取得する必要があります。

エラーログ

07-11 13:06:23.263: ERROR/AndroidRuntime(989): Uncaught handler: thread main exiting due to uncaught exception
07-11 13:06:23.273: ERROR/AndroidRuntime(989): java.lang.NullPointerException
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at com.artox.relax.inf.RestaurantListBaseActivity$RestaurantListAdapter.getView(RestaurantListBaseActivity.java:95)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.AbsListView.obtainView(AbsListView.java:1274)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.ListView.makeAndAddView(ListView.java:1668)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.ListView.fillDown(ListView.java:637)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.ListView.fillFromTop(ListView.java:694)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.ListView.layoutChildren(ListView.java:1521)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.AbsListView.onLayout(AbsListView.java:1113)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.view.View.layout(View.java:6830)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.view.View.layout(View.java:6830)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.LinearLayout.onLayout(LinearLayout.java:918)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.view.View.layout(View.java:6830)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:900)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.view.View.layout(View.java:6830)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.view.View.layout(View.java:6830)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.view.View.layout(View.java:6830)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.view.ViewRoot.performTraversals(ViewRoot.java:996)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.os.Looper.loop(Looper.java:123)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at android.app.ActivityThread.main(ActivityThread.java:4363)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at java.lang.reflect.Method.invokeNative(Native Method)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at java.lang.reflect.Method.invoke(Method.java:521)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-11 13:06:23.273: ERROR/AndroidRuntime(989):     at dalvik.system.NativeStart.main(Native Method)
4

2 に答える 2

0

View インスタンスに可視性を設定するには、次のようにします。

View myView = (View)findViewById(R.id.myview);
myView.setVisibility(View.GONE);
//or
myView.setVisibility(View.VISIBLE);
//or
myView.setVisibility(View.HIDDEN);

ここでドキュメントを確認できます: http://developer.android.com/reference/android/view/View.html#setVisibility%28int%29

于 2012-07-11T10:05:51.133 に答える