修复java.lang.IllegalArgumentException:找不到id 0x7f0d015b的视图

时间:2016-02-09 14:12:40

标签: android android-fragments

我在我的应用程序中使用NavigationDrawer滑动标签,当用户点击fragment项时,我从一个fragment调用另一个ListView,但我在此处获得例外名为java.lang.IllegalArgumentException: No view found for id 0x7f0d015b的人可以帮助我如何实现它,这是我的父活动调用另一个片段OnItemClick

 @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
       SalesRequest slr = (SalesRequest) parent.getItemAtPosition(position);


        Bundle bundle = new Bundle();
        bundle.putString("key_username", parent_user_name);
        bundle.putString("key_userid", parent_user_id);
        bundle.putString("key_RefId", slr.getReffID());
        bundle.putString("key_RefCode", slr.getReffNo());
        bundle.putString("key_SupportDetails", slr.getCustName());
        bundle.putString("key_SupportStatus", slr.getSTATUS());
        Chat_fragment chat_fragment = new Chat_fragment();
        chat_fragment.setArguments(bundle);
        FragmentTransaction xfragmentTransaction = fragment.beginTransaction();
        xfragmentTransaction.replace(R.id.containerView, chat_fragment).commit();

    }

这是logcat:

  java.lang.IllegalArgumentException: No view found for id 0x7f0d015b (android.lotus.com.androidmis:id/containerView) for fragment Chat_fragment{21da8b98 #0 id=0x7f0d015b}
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1059)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:149)
    at android.app.ActivityThread.main(ActivityThread.java:5061)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603)
    at dalvik.system.NativeStart.main(Native Method)

Chat_fragment

public class Chat_fragment extends Fragment implements View.OnClickListener {
   ProgressDialog progressdialog, progressdialog_1;
String tempstr;
   StringBuilder strBulder;
   Button btn_getPOitem;
   Spinner spinner_POrderList;

   String UserName, UserID;
   RatingBar complainrating;

   LinearLayout lnrlayout;

   ArrayAdapter<String> SupplierNameAdapter;

   AutoCompleteTextView Auto_txt_SuppName;

   List<Complaint> Complaintlist;
   List<Complaintfeedback> ComplainFeedbackList;

   ListView lst_SupportfeedBack;
   String FlagList;
   String key_RefId, key_RefCode;
   ImageView btn_Addfeedback;
   EditText Etxt_Feedback;
   String Status, Detail;
   ImageView btn_Refresh;
   View Root_view;

   @Nullable
   @Override
   public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      Root_view = inflater.inflate(R.layout.activity_feedbacklist,null);
      Bundle chat_bundle  = new Bundle();
      chat_bundle = this.getArguments();
      UserName = chat_bundle.getString("key_username");
      UserID = chat_bundle.getString("key_userid");
      key_RefId = chat_bundle.getString("key_RefId");
      key_RefCode = chat_bundle.getString("key_RefCode");
      Status = chat_bundle.getString("key_SupportStatus");
      Detail = chat_bundle.getString("key_SupportDetails");
      btn_Refresh = (ImageView)Root_view.findViewById(R.id.btn_Refresh);
      btn_Refresh.setOnClickListener(this);

      btn_Addfeedback = (ImageView)Root_view.findViewById(R.id.btn_Addfeedback);
      btn_Addfeedback.setOnClickListener(this);
      Etxt_Feedback = (EditText)Root_view.findViewById(R.id.txt_Message);

      complainrating = (RatingBar)Root_view.findViewById(R.id.complainrating);
      btn_Addfeedback.setVisibility(View.VISIBLE);
      Etxt_Feedback.setVisibility(View.VISIBLE);
      complainrating.setVisibility(View.GONE);
      lst_SupportfeedBack = (ListView)Root_view.findViewById(R.id.myfeedbackList);

      progressdialog = new ProgressDialog(getActivity());
      progressdialog_1 = new ProgressDialog(getActivity());
      progressdialog.setMessage("Downloading SO Data");
      new getSupportFeedBack().execute("GetAnyList", "1023", key_RefCode);
      return Root_view;
   }
   String POID;
   String PONO;
   @Override
   public void onClick(View v) {
      String Flage;
      String SuppCode;
      switch (v.getId()) {
         case R.id.btn_Refresh:
            new getSupportFeedBack().execute("GetAnyList", "1023", key_RefCode);

            Log.i("key_RefId", key_RefId);
            break;

         case R.id.btn_Addfeedback:
            String FeedBack = Etxt_Feedback.getText().toString();
            if (FeedBack.equalsIgnoreCase("")) {
               Toast.makeText(getActivity(),
                       "Can not be Blank", Toast.LENGTH_SHORT).show();
            } else {
               new setSupportFeedBack().execute("InsertValues", "1022",
                       key_RefId, key_RefCode, "SUB", FeedBack, UserID,
                       UserName, UserName, "", "", "", "", "", "", "");

            }
            break;

        /* case R.id.btn_Cancelfeedback:

            break;*/
         default:
            break;

      }
   }

   class getSupportFeedBack extends AsyncTask<String, Integer, String> {

      @Override
      protected void onPreExecute() {
         // TODO Auto-generated method stub
         // super.onPreExecute();
         Log.i("RITESH", "onPreExecuteSOAL");
         progressdialog_1.setMessage("Downloading Chat List");
         progressdialog_1.show();
      }

      @Override
      protected String doInBackground(String... params) {
         // TODO Auto-generated method stub
         try {
            String TempMethod = params[0];
            String Flag = params[1];
            String UserID = params[2];

            SoapObject request = new SoapObject(NAME_SPACE, TempMethod);
            request.addProperty("Flag", Flag);
            request.addProperty("value1", UserID);
            request.addProperty("value2", "");
            request.addProperty("value3", "");
            request.addProperty("value4", "");
            request.addProperty("value5", "");
            request.addProperty("value6", "");
            request.addProperty("value7", "");
            request.addProperty("value8", "");
            request.addProperty("value9", "");
            request.addProperty("value10", "");

            Log.i("RITESH", "DOINBACK SOAP" + TempMethod + "" + Flag + " "
                    + UserID);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);

            Log.i("RITESH", "DOINBACK SOAP");
            Log.i("RITESH", "method name" + TempMethod);

            HttpTransportSE Android_HttpTransport = new HttpTransportSE(URL);
            Android_HttpTransport.debug = true;
            Log.i("RITESH", "HttpTransportSE");
            Log.i("RITESH", "method name" + NAME_SPACE + TempMethod);
            Android_HttpTransport.call(NAME_SPACE + TempMethod, envelope);
            Log.i("RITESH", "CALL HttpTransportSE");
            // SoapObject result = (SoapObject)envelope.bodyIn;
            String responseXml = Android_HttpTransport.responseDump;
            // String responseXml1 = envelope.getResponse().toString();
            Log.i("responseDump", responseXml);
            // Log.i("getResponse", responseXml1);
            return responseXml;

         } catch (Exception ex) {
            ex.printStackTrace();
         }
         return null;
      }

      @Override
      protected void onPostExecute(String result) {
         // TODO Auto-generated method stub
         // super.onPostExecute(result);
         progressdialog_1.dismiss();

         String tempUser = "";
         int tempRowid=1 ;
         int tempCount=1;
         try {

            if (result == null) {
               Toast.makeText(getActivity(),
                       "Error while reading data", Toast.LENGTH_SHORT)
                       .show();
            } else {

               result = result.replaceAll("[\\\t|\\\n|\\\r]", " ");

               ComplainFeedbackList = ParseComplaintFeedbackXMLData(result);

               for (int i = 0; i < ComplainFeedbackList.size(); i++) {
                  Complaintfeedback temp = ComplainFeedbackList.get(i);

                  Log.i("MIS", "Temp_UserName " + UserName
                          + "temp.getCreatedBy() " + temp.getCreatedBy());

                  Log.i("MIS", temp.toString());
                        /*if (i == 0) {
                            tempUser = temp.getCreatedBy();
                        }*/

                  if (UserName.equalsIgnoreCase(temp.getCreatedBy())) {
                     ComplainFeedbackList.get(i).setRowid(0);
                     //tempUser = temp.getCreatedBy();
                  } else {
                     //ComplainFeedbackList.get(i).setRowid(1);
                            /*if(tempUser.equalsIgnoreCase(temp.getCreatedBy())){
                                ComplainFeedbackList.get(i).setRowid(1);
                                tempUser = temp.getCreatedBy();
                            }
                            else
                            {
                                tempUser = temp.getCreatedBy();
                                ComplainFeedbackList.get(i).setRowid(3);
                                tempRowid=3;
                            }*/

                     if(i>0)
                     {
                        if(ComplainFeedbackList.get(i).getCreatedBy().equalsIgnoreCase(ComplainFeedbackList.get(i-1).getCreatedBy()))
                        {
                           ComplainFeedbackList.get(i).setRowid(tempRowid);
                           tempUser = temp.getCreatedBy();
                           //tempRowid=1;
                        }
                        else
                        {
                           tempCount+=1;
                           tempUser = temp.getCreatedBy();
                           if(tempCount%2==1){
                              tempRowid=3;
                           }
                           else
                           {
                              tempRowid=1;
                           }
                           ComplainFeedbackList.get(i).setRowid(tempRowid);
                        }
                     }
                  }
               }

               Log.i("Chat Rec", result);
               Support_ComplainFeedbackAdapter TR_addapter = new Support_ComplainFeedbackAdapter(
                       getActivity(), 0,
                       ComplainFeedbackList, UserName);
               lst_SupportfeedBack.setAdapter(TR_addapter);
               TR_addapter.notifyDataSetChanged();

               lst_SupportfeedBack.setSelection(lst_SupportfeedBack.getCount());

               if (ComplainFeedbackList.isEmpty()) {
                  Toast.makeText(getActivity(),
                          "No Chat Found", Toast.LENGTH_LONG).show();
               }
            }

         } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         } catch (SAXException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }

         Log.i("RITESH", result);

      }

      public List<Complaintfeedback> ParseComplaintFeedbackXMLData(String XML)
              throws SAXException, ParserConfigurationException,
              UnsupportedEncodingException, IOException {
         XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser()
                 .getXMLReader();

         ComplaintFeedbackParser ComplaintHandler = new ComplaintFeedbackParser();
         xmlReader.setContentHandler(ComplaintHandler);
         xmlReader.parse(new InputSource(
                 (InputStream) new ByteArrayInputStream(XML
                         .getBytes("UTF-8"))));

         return ComplaintHandler.getComplaintfeedbackList();
      }
   }

   class setSupportFeedBack extends AsyncTask<String, Integer, String> {

      @Override
      protected void onPreExecute() {
         // TODO Auto-generated method stub
         super.onPreExecute();
      }

      @Override
      protected String doInBackground(String... params) {
         // TODO Auto-generated method stub
         String TempMethod = params[0];
         String Flag = params[1];
         String value1 = params[2];
         String value2 = params[3];
         String value3 = params[4];
         String value4 = params[5];
         String value5 = params[6];
         String value6 = params[7];
         String value7 = params[8];
         String value8 = params[9];
         String value9 = params[10];
         String value10 = params[11];

         try {
            SoapObject request = new SoapObject(NAME_SPACE, TempMethod);
            request.addProperty("Flag", Flag);
            request.addProperty("value1", value1);
            request.addProperty("value2", value2);
            request.addProperty("value3", value3);
            request.addProperty("value4", value4);
            request.addProperty("value5", value5);
            request.addProperty("value6", value6);
            request.addProperty("value7", value7);
            request.addProperty("value8", value8);
            request.addProperty("value9", value9);
            request.addProperty("value10", value10);

            Log.i("FlagId", key_RefId);
            Log.i("Chat", value2);

            Log.i("Message", value4);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            HttpTransportSE Android_HttpTransport = new HttpTransportSE(URL);
            Android_HttpTransport.debug = true;
            Android_HttpTransport.call(NAME_SPACE + TempMethod, envelope);
            String responseXml = envelope.getResponse().toString();

            String responseXml1 = Android_HttpTransport.responseDump;
            // String responseXml1 = envelope.getResponse().toString();
            Log.i("responseDump", responseXml1);

            return responseXml;
         } catch (Exception ex) {
            ex.printStackTrace();
         }

         return null;

      }

      @Override
      protected void onPostExecute(String result) {
         // TODO Auto-generated method stub
         // super.onPostExecute(result);

         if (result == null) {
            Toast.makeText(getActivity(),
                    "Error while reading data", Toast.LENGTH_SHORT).show();
         } else if (result.equals("0")) {
            Toast.makeText(getActivity(),
                    "Error while Cancel Chat Request", Toast.LENGTH_SHORT)
                    .show();
         } else if (result.equals("1")) {
            Toast.makeText(getActivity(),
                    "Chat Sent Sucessful", Toast.LENGTH_SHORT).show();
            Etxt_Feedback.setText("");
            new getSupportFeedBack().execute("GetAnyList", "1023",
                    key_RefCode);

         } else {
            Toast.makeText(getActivity(),
                    "Not Updated result  " + result, Toast.LENGTH_SHORT)
                    .show();
         }

      }

   }


}

1 个答案:

答案 0 :(得分:0)

问题是没有id&#34; containerView&#34;在布局文件中。请检查您的xml文件。