有没有可能我的编辑文本会在第二行开始输入?假设第一行是“enter”。有可能吗?如果是这样,怎么办?
这是我说的代码。你能找到一个解决办法为什么它总是不读第1行。我的解决方案是将第一行设为默认的“enter”。或者你可以再找一个?
public class TestTCP
{
private static final int PORT = 1475;
private static ServerSocket serverSocket;
private static Socket clientSocket;
private static InputStreamReader inputStreamReader;
private static BufferedReader bufferedReader;
private static String message;
private static String multiple;
public static void main(String[] args)
{
try
{
serverSocket = new ServerSocket(PORT, 0, InetAddress.getLocalHost());
System.out.println("IP: " + serverSocket.getInetAddress() + " Port: " + serverSocket.getLocalPort());
} catch (IOException e)
{
System.out.println("Could not listen on port: 1447");
}
System.out.println("Server started. Listening to the port 1447");
while (true)
{
try
{{
clientSocket = serverSocket.accept(); // accept the client connection
inputStreamReader = new InputStreamReader(clientSocket.getInputStream());
bufferedReader = new BufferedReader(inputStreamReader); // get the client message
message = bufferedReader.readLine();
while ((message = bufferedReader.readLine()) != null) {
System.out.println("Message from Table 1: " + message);}
inputStreamReader.close();
clientSocket.close();}
} catch (IOException ex)
{
ex.printStackTrace();
System.out.println("Problem in message reading");
}
finally {
try {
if (bufferedReader != null)bufferedReader.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}}
最佳答案
试试这个
EditText mEditText;
@Override onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mEditText = (EditText) findViewById(R.id.edittext);
mEditText.append("\n");
}
关于java - 如何在edittext的第二行开始输入?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18496852/