安卓按钮跳转java代码 android按钮跳转

java按一下按钮就能跳到另一个界面怎么实现java实现的简单登录页面,从一个按钮点击后跳转的页面的jframe写法:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class jb{
public static void main(String args[]){
JFrame f=new JFrame("点我跳转");
Container contentPane=f.getContentPane();
contentPane.setLayout(new GridLayout(1,2));
Icon icon=new ImageIcon("b.jpg");
JLabel label2=new JLabel("a",icon,JLabel.CENTER);
label2.setHorizontalTextPosition(JLabel.CENTER);
contentPane.setLayout(new FlowLayout( FlowLayout.CENTER,10,10));
JButton bb=new JButton("图片");
bb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFrame bf=new JFrame("新窗体");
Icon icon=new ImageIcon("enter.jpg");
JLabel label2=new JLabel(icon);
bf.getContentPane().add(label2);
bf.setSize(300,360);
bf.show();
}});
contentPane.add(label2);
contentPane.add(bb);
f.pack();
f.show();
}}
安卓中如何实现页面跳转安卓实现页面跳转及传递参数教程:
用类名跳转
Intent负责对应用中一次操作的动作、动作涉及数据、附加数据进行描述安卓按钮跳转java代码 , Android则根据此Intent的描述, 负责找到对应的组件,将 Intent传递给调用的组件,并完成组件的调用 。Intent在这里起着实现调用者与被调用者之间的解耦作用 。
Intent传递过程中 , 要找到目标消费者(另一个Activity,IntentReceiver或Service),也就是Intent的响应者 。
Java代码 package com.Android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
public class FormStuff extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.formstuff);
final ImageButton button = (ImageButton) findViewById(R.id.android_button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// 用类名跳转 , 需要在AndroidManifest.xml中申明activity
Intent intent = new Intent(FormStuff.this, HelloTabWidget.class);
startActivity(intent);
}
});
}
复制代码Xml代码 ?xml version="1.0" encoding="utf-8"?
manifest xmlns:android=""
package="com.Android" android:versionCode="1" android:versionName="1.0"
application android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar"
activity android:name=".FormStuff" android:label="@string/app_name"
intent-filter
action android:name="android.intent.action.MAIN" /
category android:name="android.intent.category.LAUNCHER" /
/intent-filter
/activity
!--申明activity--
activity android:name="HelloTabWidget"/activity
/application
uses-sdk android:minSdkVersion="4" /
/manifest
使用Action跳转实现
使用Action跳转,如果有一个程序的 AndroidManifest.xml中的某一个Activity的IntentFilter段中定义安卓按钮跳转java代码了包含了相同的Action那么这个Intent 就与这个目标Action匹配 。如果这个IntentFilter段中没有定义 Type,Category,那么这个 Activity就匹配了 。但是如果手机中有两个以上的程序匹配 , 那么就会弹出一个对话可框来提示说明 。
Action的值在Android中有很多预定义,如果想直接转到你自己定义的Intent接收者,可以在接收者的 IntentFilter中加入一个自定义的Action值(同时要设定 Category值为"android.intent.category.DEFAULT"),在Intent中设定该值为Intent的 Action,就直接能跳转到自己的Intent接收者中 。因为这个Action在系统中是唯一的 。
data/type,可以用Uri来做为data,比如Uri uri = Uri.parse();
Intent i = new Intent(Intent.ACTION_VIEW,uri);手机的Intent分发过程中 , 会根据 的scheme判断出数据类型type
手机的Brower则能匹配它,在Brower的Manifest.xml中的IntenFilter中首先有ACTION_VIEW Action,也能处理http:的type 。
至于分类Category,一般不要去在Intent中设置它 , 如果写Intent的接收者,就在Manifest.xml的 Activity的 IntentFilter中包含android.category.DEFAULT,这样所有不设置 Category(Intent.addCategory(String c);)的Intent都会与这个Category匹配 。
extras(附加信息) , 是其它所有附加信息的集合 。使用extras可以为组件提供扩展信息,比如,如果要执行“发送电子邮件”这个动作 , 可以将电子邮件的标题、正文等保存在extras里,传给电子邮件发送组件 。
Java代码 package com.android.edit_text;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
public class MyEditText extends Activity {
private TextView m_TextView;
private EditText m_EditText;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
m_EditText = (EditText) this.findViewById(R.id.EditText01);
m_EditText.setOnKeyListener(editTextKeyListener);
}
private EditText.OnKeyListener editTextKeyListener = new EditText.OnKeyListener() {
@Override
public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
// action跳转,需要在AndroidManifest.xml中配置action
Intent i = new Intent("android.intent.action.mydialog");
MyEditText.this.startActivity(i);
return false;
}
};
}
复制代码Xml代码 ?xml version="1.0" encoding="utf-8"?
manifest xmlns:android=""
package="com.android.edit_text" android:versionCode="1"
android:versionName="1.0"
application android:icon="@drawable/icon" android:label="@string/app_name"
activity android:name=".MyEditText" android:label="@string/app_name"
intent-filter
action android:name="android.intent.action.MAIN" /
category android:name="android.intent.category.LAUNCHER" /
/intent-filter
/activity
!--配置跳转activity--
activity android:name="com.android.dialog.MyDialog"
intent-filter
!--配置action路径--
action android:name="android.intent.action.mydialog" /
category android:name="android.intent.category.DEFAULT" /
/intent-filter
/activity
/application
uses-sdk android:minSdkVersion="7" /
/manifest
java中如何做到界面的跳转?假如有两个frame,分别为frame1,frame2,frame1加个按钮实现跳转.frame1代码如下
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class frame1 extends JFrame implements ActionListener{
/**
* @param args
*/
private JButton jb;
public frame1()
{
this.setSize(300, 200);
this.setLocation(300, 400);
jb=new JButton("跳转");
this.add(jb);
jb.addActionListener(this);//加入事件监听
this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame1 frame=new frame1();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jb)
{
this.dispose();//点击按钮时frame1销毁,new一个frame2
new frame2();
}
}
}
frame2是个单纯的界面
import javax.swing.JButton;
import javax.swing.JFrame;
public class frame2 extends JFrame{
/**
* @param args
*/
public frame2()
{
this.setSize(300, 200);
this.setLocation(300, 400);
this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame2 frame=new frame2();
}
}
java程序中如何实现单击页面a中的按钮跳转到页面bjava程序中安卓按钮跳转java代码的jsp页面点击按钮跳转到页面b的方式如下安卓按钮跳转java代码:
1.jsp页面的方式如下:a href="https://www.04ip.com/post/....b.jsp"跳转/a
response.sendRedirect("b.jsp")
jsp:forward page="b.jsp"/
2.在swing里安卓按钮跳转java代码,给button加一个监听器安卓按钮跳转java代码 , 然后在监听事件中打开另一个页面 。
在jsp或是静态网页里安卓按钮跳转java代码,onclick=“JavaScript:window.location=’xx‘”
android studio 怎么实现按钮跳转1)页面跳转
View Code
2)网页跳转
View Code
3)完整代码
activity_main.xml:
View Code
next.xml:(准备跳转到页面的布局)
View Code
MainActivity.java:
View Code
nextActivity.java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package com.example.jumpto;
import android.os.Bundle;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class nextActivity extends AppCompatActivity {
Button Btn1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.next);
}
}
【安卓按钮跳转java代码 android按钮跳转】关于安卓按钮跳转java代码和android按钮跳转的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读