android 一个activity调用另一个activity,窗口化显示
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配吧
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:layout_height="wrap_content"
>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20px"
android:text="@string/channelname"
/>
android:layout_width="400px"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/nameLable"
android:layout_alignTop="@id/nameLable"
/>
android:layout_height="wrap_content"
>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20px"
android:text="@string/channeladdress"
/>
android:layout_width="400px"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/ageLable"
android:layout_alignTop="@id/ageLable"
/>
android:layout_height="wrap_content"
>
4、=========================================================================
android的AndroidManifest.xml文件配置activity,代码如下:
android:theme="@android:style/Theme.Dialog"
android:label="@string/app_name" >
更多相关文章
- android surfaceView参考
- 改变android 选项卡的背景色
- android notification 事件
- TextView 在xml文件中的解释
- Android监听WebView滑动到底部
- Android往SD卡上存储文件
- android p 充拔电提示音
- android notification 事件
- NPM 和webpack 的基础使用