在编辑文本中转换为字符串时出现问题。
输入编辑文字IP编号
public class Client extends AppCompatActivity implements View.OnClickListener {
public static final String TAG = Client.class.getSimpleName();
public static final int SERVERPORT = 3000;
ClientThread clientThread;
Thread thread;
TextView messageTv;
String text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
messageTv = (TextView) findViewById(R.id.messageTv);
EditText SERVER_IP = (EditText) findViewById(R.id.ipnumber);
text = SERVER_IP.getText().toString();
}
答案 0 :(得分:0)
你的问题不是很清楚,但这是你如何做的
EditText eTxt=(EditText)findViewById(R.id.ipnumber);
TextView tView=new TextView(this);
tView.setText("Your Text is="+eTxt.getText());
setContentView(tView);
答案 1 :(得分:0)
嗨,这有点不清楚但是通过查看你的代码,尝试指定“ipnumber”EditText所属的布局,如http://android-er.blogspot.co.za/2011/02/how-to-retrieve-string-from-edittext.html
所示