您的位置:首页 > 移动开发 > Android开发

android 一个activity调用另一个activity,窗口化显示

2012-11-30 15:01 537 查看
1、======================================================

调用的AAactivity.java代码如下:

Intent intent = new Intent(AAActivity.this, BBActivity.class);

   startActivity(intent);

2、======================================================

新建BBActivity.java,代码入下:

package com.weiny;

import android.app.Activity;

import android.app.AlertDialog;

import android.content.ContentValues;

import android.content.Context;

import android.content.DialogInterface;

import android.content.Intent;

import android.database.Cursor;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

import com.hh.radio.activity.HHRadioActivity;

import com.hh.radio.activity.R;

import com.hh.radio.util.ExitApplication;

import com.hh.radio.util.InternetRadioHelper;

public class UserAddChannelActivity extends Activity {

 

 private Button saveButton , cancelButton ;

 private EditText channel_name , channel_address ;

  

 public void onCreate(Bundle paramBundle) {

  super.onCreate(paramBundle);

  setContentView(R.layout.addchannel);

  ExitApplication.getInstance().addActivity(this);

  initView() ;

  saveButton.setOnClickListener(new ButtonListener()) ;

  cancelButton.setOnClickListener(new ButtonListener()) ;

 }

 /**

  * @description 初始化所有view

  */

 private void initView(){

  this.saveButton = (Button)findViewById(R.id.savebutton) ;

  this.cancelButton = (Button)findViewById(R.id.cancelbutton) ;

  this.channel_name = (EditText)findViewById(R.id.channel_name) ;

  this.channel_address = (EditText)findViewById(R.id.channel_address) ;

 }

 

 /**

  * @description 选择按钮后的事件

  */

 private void clickControllerBar(View v) {

  switch (v.getId()) {

  case R.id.savebutton: {

   String editChannelNameStr = ((EditText)findViewById(R.id.channel_name)).getText()+"" ;

   String editChannelURLStr = ((EditText)findViewById(R.id.channel_address)).getText()+"" ;

   finish() ;

   Intent intent = new Intent(BBActivity.this, AAActivity.class);

   startActivity(intent);

   break;

  }

  case R.id.cancelbutton: {

   finish() ;

   break;

  }

  default:

   break;

  }

 }

 

 class ButtonListener implements OnClickListener {

  @Override

  public void onClick(View v) {

   clickControllerBar(v);

  }

 }

 

}

3、====================================================

BBActivity的.xml文件,代码如下:android:text自己在strings.xml配吧

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    >

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

     android:layout_width="fill_parent"

     android:layout_height="wrap_content"

     >

  <TextView 

      android:id="@+id/nameLable"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:textSize="20px"

      android:text="@string/channelname"

      />

  <EditText 

      android:id="@+id/channel_name"

      android:layout_width="400px"

      android:layout_height="wrap_content"

      android:layout_toRightOf="@id/nameLable"

      android:layout_alignTop="@id/nameLable"

      />

 </RelativeLayout>

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

     android:layout_width="fill_parent"

     android:layout_height="wrap_content"

     >

  <TextView 

      android:id="@+id/ageLable"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:textSize="20px"

      android:text="@string/channeladdress"

      />

  <EditText 

      android:id="@+id/channel_address"

      android:layout_width="400px"

      android:layout_height="wrap_content"

      android:layout_toRightOf="@id/ageLable"

      android:layout_alignTop="@id/ageLable"

      />

 </RelativeLayout>

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

     android:layout_width="fill_parent"

     android:layout_height="wrap_content"

     >

  <Button

       android:id="@+id/savebutton"

    android:layout_width="wrap_content"

       android:layout_height="wrap_content"

       android:text="@string/sure"

   />

  <Button

       android:id="@+id/cancelbutton"

    android:layout_width="wrap_content"

       android:layout_height="wrap_content"

       android:text="@string/cancel"

       android:layout_toRightOf="@id/savebutton"

   />

 </RelativeLayout>

</LinearLayout>

 

4、=========================================================================

android的AndroidManifest.xml文件配置activity,代码如下:

 <activity android:name="com.weiny.BBActivity"

            android:theme="@android:style/Theme.Dialog"

            android:label="@string/app_name" >

            <intent-filter >

                <action android:name="com.hh.radio.useradd"/>

                <category android:name="android.intent.category.DEFAULT"/>

            </intent-filter>

        </activity>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android
相关文章推荐