【发布时间】:2016-07-22 12:39:26
【问题描述】:
我正在制作一个可以显示不同产品图像的应用程序,并且有一个按钮可以选择它们,这个按钮会将信息发送到localhost。
但是,EditText 不起作用。如果我这样做了
ItemNote=(EditText) imageLayout.getActivity().findViewById(R.id.ItemNote);
它将起作用,但仅适用于该选项,并且再次停止适用于不同的选项。
@Override
public Object instantiateItem(ViewGroup view, int position) {
View imageLayout = inflater.inflate(R.layout.item_pager_image, view, false);
assert imageLayout != null;
ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);
ItemNote=(EditText) imageLayout.findViewById(R.id.ItemNote);
ItemQuantity=(EditText)imageLayout.findViewById(R.id.ItemQuantity);
ItemName=(TextView) imageLayout.findViewById(R.id.ItemName);
ItemPrice=(TextView)imageLayout.findViewById(R.id.ItemPrice);
choose=(Button) imageLayout.findViewById(R.id.choose);
quantity=ItemQuantity.getText().toString();
note=ItemNote.getText().toString();
name=ItemName.getText().toString();
price=ItemPrice.getText().toString();
choose.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//getting input for item quantity and Item Extraa note
String Order= " "+name+" "+'('+quantity+')'+" With "+note+" Price : "+price+'\n';
ItemNote.setText(""); // Reset the text field to blank
ItemQuantity.setText(""); // Reset the text field to blank
messsage = Order; // get the text message on the text field
SendMessage sendMessageTask = new SendMessage();
sendMessageTask.execute();
}
});
【问题讨论】:
标签: android android-edittext localhost