我有两个类......这两个类都是扩展活动..我需要在android开发的主类上调用其他类方法..紧急..请...我做了类似子类sub = new subclass()的东西。 ..没有用..
在第1活动班
package org.me.intent_testing;
import android.app.Activity; import android.os.Bundle; import android.widget.; import android.view.; import android.content.Intent;
/** * * @author pavankumar */
public class FirstActivity extends Activity {
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
// Button orderButton = (Button)findViewById(R.id.order); Button orderButton = new Button(this); orderButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(FirstActivity.this, secondActivity.class);
startActivity(intent);
}
});
} }
In secondActivity class
package org.me.intent_testing;
/** * * @author pavankumar */
import android.app.Activity; import android.os.Bundle; import android.widget.; import android.view.; import android.content.Intent;
public class secondActivity extends Activity {
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // setContentView(R.layout.order);
// Button orderButton = (Button) findViewById(R.id.end); Button orderButton = new Button(this); orderButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
} }
在AndroidManifest.xml中
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.me.intent_testing">
<application>
<activity android:name=".FirstActivity" android:label="FirstActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".OrderScreen" />
</application>
</manifest>
我有两个类之间的链接问题..
答案 0 :(得分:0)