请问这段Android代码的解决办法
packagecom.example.activitytest;importandroid.app.Activity;importandroid.os.Bundle;im...
package com.example.activitytest;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.Toast;
public class FirstActivity extends Activity {
@Override
protected void onCreate(Bundle saveInstanceState){
super.onCreate(saveInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.first_layout);
Log.d("FirstWorldActivity", "msg");
Button button1 = (Button) findViewById(R.id.button_1);
button1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
Toast.makeText(FirstActivity.this,"You clicked button 1",Toast.LENGTH_SHORT).show();
}
});
}
}
提示类型 View 中的方法 setOnClickListener(View.OnClickListener)对于参数(new OnClickListener(){})不适用 展开
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.Toast;
public class FirstActivity extends Activity {
@Override
protected void onCreate(Bundle saveInstanceState){
super.onCreate(saveInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.first_layout);
Log.d("FirstWorldActivity", "msg");
Button button1 = (Button) findViewById(R.id.button_1);
button1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
Toast.makeText(FirstActivity.this,"You clicked button 1",Toast.LENGTH_SHORT).show();
}
});
}
}
提示类型 View 中的方法 setOnClickListener(View.OnClickListener)对于参数(new OnClickListener(){})不适用 展开
展开全部
new OnClickListener换成new View.OnClickListener
追问
[2015-10-17 11:56:56 - ActivityTest] Failed to install ActivityTest.apk on device 'emulator-5554': null
[2015-10-17 11:56:56 - ActivityTest] com.android.ddmlib.InstallException
追答
log不完整,所有不好看是啥问题,最好有多点log;
从现有的log看是安装失败了。
尝试重连设备再安装一下。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询