-5
代碼:如何從編輯文本值的標籤活動的片段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;
}
什麼是錯誤?活動中是edittext嗎? –
你的意思是說,如何從EditText檢索值? –
沒有它的片段,但即時通訊無法獲取edittext的值 –