我有很多布局,但我只想从几种不同的布局中获取字符串。 我的问题是我得到的只是空......
这是我的代码:
LayoutInflater factory = getLayoutInflater();
View input = factory.inflate(R.layout.activity_inputan, null);
View coordinate = factory.inflate(R.layout.activity_location, null);
View scan = factory.inflate(R.layout.activity_scan, null);
EditText prod = (EditText) input.findViewById(R.id.product);
EditText bran = (EditText) input.findViewById(R.id.brand);
EditText plac = (EditText) input.findViewById(R.id.place);
EditText date = (EditText) input.findViewById(R.id.date);
EditText pric = (EditText) input.findViewById(R.id.price);
EditText lat = (EditText) coordinate.findViewById(R.id.latitude);
EditText longi = (EditText) coordinate.findViewById(R.id.longitude);
EditText format = (EditText) scan.findViewById(R.id.format);
EditText content = (EditText) scan.findViewById(R.id.content);
String a = prod.getText().toString();
String b = bran.getText().toString();
String c = plac.getText().toString();
String d = date.getText().toString();
String e = pric.getText().toString();
String f = lat.getText().toString();
String g = longi.getText().toString();
String h = format.getText().toString();
String i = content.getText().toString();
我尝试通过吐司以另一种布局显示它,但它是空的。 任何帮助或建议表示赞赏。
答案 0 :(得分:0)
创建LayoutInflater。
LayoutInflater inf = getLayoutInflater();
View v1 = inf.inflate(R.layout.regis, null);
EditText user = (EditText) v1.findViewById(R.id.edt1);
String usr = user.getText().toString();