• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

如何从编辑文本值的标签活动的片段Android Studio中3.0.1

Android 来源:RAJ SHINDE 6次浏览

代码:如何从编辑文本值的标签活动的片段Android Studio中3.0.1

public class CustomerDetails extends Fragment { 
    EditText CustomerCode,FullName,AddressLine1,AddressLine2,MobileNo,EmailId,CustomerType; 
    Button Submit; 
    IonExchangeDataBasehelper ionexchangedatabase; 

     @Override 
     public View onCreateView(LayoutInflater inflater, ViewGroup container, 
           Bundle savedInstanceState) { 
      // Inflate the layout for this fragment 
    //super.onCreate(savedInstanceState); 
      // View v =inflater.inflate(R.layout.fragment_customer_details,container,false); 
      View v =getActivity().getLayoutInflater().inflate(R.layout.fragment_customer_details,null); 
      CustomerCode=(EditText)v.findViewById(R.id.CustomerCode); 
      FullName=(EditText)v.findViewById(R.id.FullName); 
      AddressLine1=(EditText)v.findViewById(R.id.AddressLine1); 
      AddressLine2=(EditText)v.findViewById(R.id.AddressLine2); 
      MobileNo=(EditText)v.findViewById(R.id.MobileNo); 
      EmailId=(EditText)v.findViewById(R.id.EmailId); 
      CustomerType=(EditText)v.findViewById(R.id.CustomerType); 
      Submit=(Button)v.findViewById(R.id.Submit); 

      Submit.setOnClickListener(new View.OnClickListener() { 
       @Override 
       public void onClick(View view) { 
        String abc = CustomerCode.getText().toString(); 
        Toast.makeText(getActivity(),"hhh :" ,Toast.LENGTH_SHORT).show(); 
        // database(); 
       } 
      }); 

      return v; 

     } 


===========解决方案如下:

清理你的代码;尝试并说,如果你仍然有错误

public class CustomerDetails extends Fragment { 
       EditText customerCode,fullName,addressLine1,addressLine2,mobileNo,emailId,customerType; 
       Button submit; 
       IonExchangeDataBasehelper ionexchangedatabase; 

        @Override 
     public View onCreateView(LayoutInflater inflater, ViewGroup container, 
     Bundle savedInstanceState) { 
     // Inflate the layout for this fragment 
     v = inflater.inflate(R.layout.fragment_customer_details, container, 
     false); 
     // get the reference of views 
         customerCode=(EditText)v.findViewById(R.id.CustomerCode); 
         fullName=(EditText)v.findViewById(R.id.FullName); 
         addressLine1=(EditText)v.findViewById(R.id.AddressLine1); 
         addressLine2=(EditText)v.findViewById(R.id.AddressLine2); 
         mobileNo=(EditText)v.findViewById(R.id.MobileNo); 
         emailId=(EditText)v.findViewById(R.id.EmailId); 
         customerType=(EditText)v.findViewById(R.id.CustomerType); 
         submit=(Button)v.findViewById(R.id.Submit); 

         submit.setOnClickListener(new View.OnClickListener() { 
          @Override 
          public void onClick(View view) { 
           String abc = customerCode.getText().toString(); 
           Toast.makeText(getActivity(), abc ,Toast.LENGTH_SHORT).show(); 
           // database(); 
          } 
         }); 

         return v; 

        } 

版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)