Java 多重标记
我犯了这样的错误:Java 多重标记,java,android,Java,Android,我犯了这样的错误: "Multiple markers at this line - Syntax error, insert ";" to complete LocalVariableDeclarationStatement - Syntax error, insert "}" to complete ClassBody - Syntax error, insert "}" to complete ClassBody - Syntax error, insert ";" to compl
"Multiple markers at this line
- Syntax error, insert ";" to complete
LocalVariableDeclarationStatement
- Syntax error, insert "}" to complete ClassBody
- Syntax error, insert "}" to complete ClassBody
- Syntax error, insert ";" to complete
LocalVariableDeclarationStatement"
我一点也不缺
TimerTask getMessagesTask=new TimerTask() {
this.runOnUiThread(new Runable(){
@Override
public void run() {
newMessages=connectToserverforincomingmsgs( getmsgurl, chatnumber);
TextView tv=new TextView(Chat.this);
tv.setText(chatnumber+":"+newMessages);
LayoutParams param=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
tv.setLayoutParams(param);
((LinearLayout)findViewById(R.id.ll_chat)).addView(tv);
}});
区块报价
试试这个:
final Runnable doTaskRunnable = new Runnable() {
public void run() {
newMessages=connectToserverforincomingmsgs( getmsgurl, chatnumber);
TextView tv=new TextView(Chat.this);
tv.setText(chatnumber+":"+newMessages);
LayoutParams param=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
tv.setLayoutParams(param);
((LinearLayout)findViewById(R.id.ll_chat)).addView(tv);
}
};
TimerTask getMessagesTask = new TimerTask(){
public void run() {
MainActivity.this.runOnUiThread(doTaskRunnable);
}
};
这段代码可以工作,因为TimerTask和Runnable都需要您实现一个run方法,所以您需要两个run方法。在末尾添加一个括号“{”以关闭TimerTask