如何隐藏空白文本视图

时间:2014-06-29 01:35:38

标签: android json listview

所以我有一个JSON解析器 并且在它上面我想要检测空白的文本视图,然后如果它的空白更改,则线性布局可见性消失

这是我正在使用的代码,但它给出了NullExceptionError

    TextView fajr;
    fajr = (TextView) findViewById(R.id.fajr_iqamah_time);
    if(fajr.getText().toString().length()>0)
    {
        findViewById(R.id.fajr_iqamah).setVisibility(View.GONE);
     } 

logcat:

06-28 21:29:29.072: E/AndroidRuntime(31039): FATAL EXCEPTION: main
06-28 21:29:29.072: E/AndroidRuntime(31039): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sahaab.android.muslimzone.test/com.sahaab.muslimzone.activity.IqamahActivity}: java.lang.NullPointerException
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2266)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.app.ActivityThread.access$600(ActivityThread.java:150)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.os.Looper.loop(Looper.java:213)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.app.ActivityThread.main(ActivityThread.java:5225)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at java.lang.reflect.Method.invokeNative(Native Method)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at java.lang.reflect.Method.invoke(Method.java:525)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at dalvik.system.NativeStart.main(Native Method)
06-28 21:29:29.072: E/AndroidRuntime(31039): Caused by: java.lang.NullPointerException
06-28 21:29:29.072: E/AndroidRuntime(31039):    at com.sahaab.muslimzone.activity.IqamahActivity.onCreate(IqamahActivity.java:124)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.app.Activity.performCreate(Activity.java:5133)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-28 21:29:29.072: E/AndroidRuntime(31039):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2230)
06-28 21:29:29.072: E/AndroidRuntime(31039):    ... 12 more

基本上textview在listViewItems布局中,并且这个类使用ListView的布局(FragmentActivity因为也有map)

布局和2个活动类 https://www.dropbox.com/s/erigyxk6jp5bpct/Desktop.rar

0 个答案:

没有答案