开发者

how do i call java class methods to other java class file on android development

i hav two classes...both classes are extends activity.. i need call other class method on main class on android development..its urgent..please.. i done something like subclass sub = new subclass()...its not work..

In 1st activity class

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_test开发者_开发问答ing;

/** * * @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();
  }

});
} }

In 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>

I hv problem to linking between two classes..


Google is your friend:

http://www.droidnova.com/use-intents-to-start-other-activities,76.html

http://www.warriorpoint.com/blog/2009/05/24/android-how-to-switch-between-activities/

And you may want to reformat you code ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜