2个回答
展开全部
在AndroidManifest里面添加actvity权限:
其中一个是app的主actvity MainActvity,已经有了,就不加了,没有要手动添加,现在添加另一个:
<activity android:name="com.example.test.testActivity"></activity>
程序部分:
private TextView tv_luobo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv_luobo = (TextView) findViewById(R.id.tv_luobo);
tv_luobo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(MainActivity.this,testActivity.class);
startActivity(intent);
}
});
另一个程序:
import android.app.Activity;
import android.os.Bundle;
public class testActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
}
其中一个是app的主actvity MainActvity,已经有了,就不加了,没有要手动添加,现在添加另一个:
<activity android:name="com.example.test.testActivity"></activity>
程序部分:
private TextView tv_luobo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv_luobo = (TextView) findViewById(R.id.tv_luobo);
tv_luobo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(MainActivity.this,testActivity.class);
startActivity(intent);
}
});
另一个程序:
import android.app.Activity;
import android.os.Bundle;
public class testActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询