如果条件在自定义适配器内不起作用(getView())

时间:2015-02-04 10:39:30

标签: java android

我正在尝试使用equalignorecase()来比较两个字符串,但它不起作用,如果我将图像资源设置为imageView而没有条件,它的工作。我也使用了字符串==“”但是仍然相同错误

Java代码:

 public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder holder;
          if(convertView==null)
          {
               convertView = mInflater.inflate(R.layout.androidnewxml,parent,false);
               holder = new ViewHolder();
               holder.name = (TextView)convertView.findViewById(R.id.textView_adapter);
               holder.status= (ImageView)convertView.findViewById(R.id.showStatus);  
               holder.description= (TextView)convertView.findViewById(R.id.ShowDescription);  


               convertView.setTag(holder); 
          }else{
                holder = (ViewHolder)convertView.getTag();
          } 
                //String checkStatus="Yes";
                holder.name.setText(list1.get(position).getKITTYDATE());
                String  checkStatus= list1.get(position).getPARTICULAR();
              Log.d("status", checkStatus);
               if(checkStatus.equalsIgnoreCase("Yes"))
               {
                   holder.status.setImageResource(R.drawable.acceptbuttons);
               }

               else if(checkStatus.equalsIgnoreCase("No"))
               {
                    holder.status.setImageResource(R.drawable.declinebuttons);
               }
               else
               {

               }

                holder.description.setText(list1.get(position).getINSTALLMENT());


                Log.d("hhhhhhhhhhh","jjjjjjjj"+convertView);

          return convertView;

    }

错误:

02-04 16:04:17.976: D/====(26020): loginstatus111loginsuccess
02-04 16:04:17.996: I/Timeline(26020): Timeline: Activity_launch_request id:com.newproject time:116503075
02-04 16:04:18.106: W/ApplicationPackageManager(26020): getCSCPackageItemText()
02-04 16:04:18.446: I/Timeline(26020): Timeline: Activity_idle id: android.os.BinderProxy@42022900 time:116503522
02-04 16:04:22.676: I/Timeline(26020): Timeline: Activity_launch_request id:com.newproject time:116507754
02-04 16:04:22.716: W/ApplicationPackageManager(26020): getCSCPackageItemText()
02-04 16:04:22.806: D/bnnnnnnnn(26020): record fetch[]
02-04 16:04:22.936: I/Timeline(26020): Timeline: Activity_idle id: android.os.BinderProxy@42200398 time:116508018
02-04 16:04:24.666: I/Timeline(26020): Timeline: Activity_launch_request id:com.newproject time:116509740
02-04 16:04:24.696: W/ApplicationPackageManager(26020): getCSCPackageItemText()
02-04 16:04:24.726: D/bnnnnnnnn(26020): record fetch[com.newproject.Record@42246210, com.newproject.Record@42246710]
02-04 16:04:24.836: I/Timeline(26020): Timeline: Activity_idle id: android.os.BinderProxy@42234638 time:116509918
02-04 16:04:25.886: D/kitty name at list view(26020): Sbhs
02-04 16:04:25.886: D/kitty date at list view(26020): 4/2/2015 
02-04 16:04:25.886: D/kitty amount at list view(26020): 6,467
02-04 16:04:25.886: I/Timeline(26020): Timeline: Activity_launch_request id:com.newproject time:116510964
02-04 16:04:25.906: W/ApplicationPackageManager(26020): getCSCPackageItemText()
02-04 16:04:25.926: D/iddd iddd iddd(26020): 4
02-04 16:04:25.926: D/Hello(26020): 4
02-04 16:04:25.926: D/Hello(26020): Xgxhx
02-04 16:04:25.926: D/Hello(26020): Sbhs
02-04 16:04:25.926: D/Hello(26020): 4/2/2015 
02-04 16:04:25.936: D/bnnnnnnnn(26020): record fetch0
02-04 16:04:25.936: D/bnnnnnnnn(26020): record fetch[com.newproject.Record@4226a160]
02-04 16:04:25.946: D/hhhhhhhhhhh(26020): jjjjjjjjandroid.widget.RelativeLayout{4226e600 V.E..... ......I. 0,0-0,0}
02-04 16:04:25.966: D/hhhhhhhhhhh(26020): jjjjjjjjandroid.widget.RelativeLayout{4226e600 V.E..... ......I. 0,0-0,0}
02-04 16:04:25.996: D/hhhhhhhhhhh(26020): jjjjjjjjandroid.widget.RelativeLayout{422777e0 V.E..... ......I. 0,0-0,0}
02-04 16:04:26.026: I/Timeline(26020): Timeline: Activity_idle id: android.os.BinderProxy@422596e0 time:116511102
02-04 16:04:26.716: D/kitty name at list view(26020): Xgxhx
02-04 16:04:26.716: I/Timeline(26020): Timeline: Activity_launch_request id:com.newproject time:116511793
02-04 16:04:26.736: W/ApplicationPackageManager(26020): getCSCPackageItemText()
02-04 16:04:26.756: D/iddd iddd iddd(26020): 1
02-04 16:04:26.756: D/Hello(26020): 4
02-04 16:04:26.756: D/Hello(26020): Xgxhx
02-04 16:04:26.756: D/Hello(26020): Sbhs
02-04 16:04:26.756: D/Hello(26020): 04/02/2015
02-04 16:04:26.756: D/Hello(26020): 4
02-04 16:04:26.756: D/Hello(26020): Xgxhx
02-04 16:04:26.756: D/Hello(26020): Sbhs
02-04 16:04:26.756: D/Hello(26020): 04/03/2015
02-04 16:04:26.756: D/Hello(26020): 4
02-04 16:04:26.756: D/Hello(26020): Xgxhx
02-04 16:04:26.756: D/Hello(26020): Sbhs
02-04 16:04:26.756: D/Hello(26020): 04/04/2015
02-04 16:04:26.756: D/Hello(26020): 4
02-04 16:04:26.756: D/Hello(26020): Xgxhx
02-04 16:04:26.756: D/Hello(26020): Sbhs
02-04 16:04:26.756: D/Hello(26020): 04/05/2015
02-04 16:04:26.756: D/Hello(26020): 4
02-04 16:04:26.756: D/Hello(26020): Xgxhx
02-04 16:04:26.756: D/Hello(26020): Sbhs
02-04 16:04:26.756: D/Hello(26020): 04/06/2015
02-04 16:04:26.756: D/Hello(26020): 4
02-04 16:04:26.756: D/Hello(26020): Xgxhx
02-04 16:04:26.756: D/Hello(26020): Sbhs
02-04 16:04:26.766: D/Hello(26020): 04/07/2015
02-04 16:04:26.766: D/Hello(26020): 4
02-04 16:04:26.766: D/Hello(26020): Xgxhx
02-04 16:04:26.766: D/Hello(26020): Sbhs
02-04 16:04:26.766: D/Hello(26020): 04/08/2015
02-04 16:04:26.766: D/Hello(26020): 4
02-04 16:04:26.766: D/Hello(26020): Xgxhx
02-04 16:04:26.766: D/Hello(26020): Sbhs
02-04 16:04:26.766: D/Hello(26020): 04/09/2015
02-04 16:04:26.766: D/Hello(26020): 4
02-04 16:04:26.766: D/Hello(26020): Xgxhx
02-04 16:04:26.766: D/Hello(26020): Sbhs
02-04 16:04:26.766: D/Hello(26020): 04/10/2015
02-04 16:04:26.766: D/Hello(26020): 4
02-04 16:04:26.766: D/Hello(26020): Xgxhx
02-04 16:04:26.766: D/Hello(26020): Sbhs
02-04 16:04:26.766: D/Hello(26020): 04/11/2015
02-04 16:04:26.766: D/Hello(26020): 4
02-04 16:04:26.766: D/Hello(26020): Xgxhx
02-04 16:04:26.766: D/Hello(26020): Sbhs
02-04 16:04:26.766: D/Hello(26020): 04/12/2015
02-04 16:04:26.766: D/Hello(26020): 4
02-04 16:04:26.766: D/Hello(26020): Xgxhx
02-04 16:04:26.766: D/Hello(26020): Sbhs
02-04 16:04:26.766: D/Hello(26020): 04/01/2016
02-04 16:04:26.766: D/bnnnnnnnn(26020): record fetch0
02-04 16:04:26.766: D/bnnnnnnnn(26020): record fetch[com.newproject.Record@4228c268, com.newproject.Record@4228c848, com.newproject.Record@4228cc18, com.newproject.Record@4228cf70, com.newproject.Record@4228d2c8, com.newproject.Record@4228d620, com.newproject.Record@4228d978, com.newproject.Record@4228dcd0, com.newproject.Record@4228e028, com.newproject.Record@4228e380, com.newproject.Record@4228e6d8, com.newproject.Record@4228ea30]
02-04 16:04:26.776: D/status(26020): No
02-04 16:04:26.776: D/hhhhhhhhhhh(26020): jjjjjjjjandroid.widget.RelativeLayout{42293c10 V.E..... ......I. 0,0-0,0}
02-04 16:04:26.786: D/status(26020): No
02-04 16:04:26.786: D/hhhhhhhhhhh(26020): jjjjjjjjandroid.widget.RelativeLayout{42293c10 V.E..... ......I. 0,0-0,0}
02-04 16:04:26.786: D/AndroidRuntime(26020): Shutting down VM
02-04 16:04:26.786: W/dalvikvm(26020): threadid=1: thread exiting with uncaught exception (group=0x417e8d58)
02-04 16:04:26.796: E/AndroidRuntime(26020): FATAL EXCEPTION: main
02-04 16:04:26.796: E/AndroidRuntime(26020): Process: com.newproject, PID: 26020
02-04 16:04:26.796: E/AndroidRuntime(26020): java.lang.NullPointerException: println needs a message
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.util.Log.println_native(Native Method)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.util.Log.d(Log.java:164)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at com.newproject.Show_Dates$CustomAdapter.getView(Show_Dates.java:127)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.AbsListView.obtainView(AbsListView.java:2301)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.ListView.measureHeightOfChildren(ListView.java:1274)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.ListView.onMeasure(ListView.java:1186)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.View.measure(View.java:16677)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.View.measure(View.java:16677)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5286)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.View.measure(View.java:16677)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:762)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.View.measure(View.java:16677)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5286)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.View.measure(View.java:16677)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5286)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.View.measure(View.java:16677)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5286)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2421)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.View.measure(View.java:16677)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1927)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1119)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1301)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1006)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5652)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.Choreographer.doCallbacks(Choreographer.java:574)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.Choreographer.doFrame(Choreographer.java:544)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.os.Handler.handleCallback(Handler.java:733)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.os.Handler.dispatchMessage(Handler.java:95)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.os.Looper.loop(Looper.java:136)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at android.app.ActivityThread.main(ActivityThread.java:5426)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at java.lang.reflect.Method.invokeNative(Native Method)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at java.lang.reflect.Method.invoke(Method.java:515)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
02-04 16:04:26.796: E/AndroidRuntime(26020):    at dalvik.system.NativeStart.main(Native Method)
02-04 16:04:29.406: I/Process(26020): Sending signal. PID: 26020 SIG: 9

1 个答案:

答案 0 :(得分:0)

问题在这里:

if(checkStatus==null)
                {

                }
                else
                {
              Log.d("status", checkStatus);
               if(checkStatus.equalsIgnoreCase("Yes"))
               {
                   holder.status.setImageResource(R.drawable.acceptbuttons);
               }

               else if(checkStatus.equalsIgnoreCase("No"))
               {
                    holder.status.setImageResource(R.drawable.declinebuttons);
               }
               else
               {


               }
                }