用java做好的登陸界面,當(dāng)?shù)顷懗晒筇D(zhuǎn)到下個(gè)頁(yè)面的代碼如下:
龍子湖網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),龍子湖網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為龍子湖近千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的龍子湖做網(wǎng)站的公司定做!
如果登陸驗(yàn)證是在jsp中,那么跳轉(zhuǎn)可以寫成
1.response.sendRedirct("跳轉(zhuǎn)到頁(yè)面");
2.jsp:forward page="跳轉(zhuǎn)頁(yè)面"/
3.response.setHeader("Location","");
如果是登陸驗(yàn)證是在servlet中,那么中轉(zhuǎn)可以寫成
1.response.sendRedirect("/a.jsp");
2.RequestDispatcher dispatcher = request.getRequestDispatcher("/a.jsp");
dispatcher .forward(request, response);
也可以使用js代碼實(shí)現(xiàn):
script
function validate(){
window.location.href="/index.jsp";
}
/script
假如有兩個(gè)frame,分別為frame1,frame2,frame1加個(gè)按鈕實(shí)現(xiàn)跳轉(zhuǎn).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("跳轉(zhuǎn)");
this.add(jb);
jb.addActionListener(this);//加入事件監(jiān)聽
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();//點(diǎn)擊按鈕時(shí)frame1銷毀,new一個(gè)frame2
new frame2();
}
}
}
frame2是個(gè)單純的界面
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();
}
}
安卓實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)及傳遞參數(shù)教程:
用類名跳轉(zhuǎn)
Intent負(fù)責(zé)對(duì)應(yīng)用中一次操作的動(dòng)作、動(dòng)作涉及數(shù)據(jù)、附加數(shù)據(jù)進(jìn)行描述,Android則根據(jù)此Intent的描述, 負(fù)責(zé)找到對(duì)應(yīng)的組件,將 Intent傳遞給調(diào)用的組件,并完成組件的調(diào)用。Intent在這里起著實(shí)現(xiàn)調(diào)用者與被調(diào)用者之間的解耦作用。
Intent傳遞過(guò)程中,要找到目標(biāo)消費(fèi)者(另一個(gè)Activity,IntentReceiver或Service),也就是Intent的響應(yīng)者。
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)?{?
//?用類名跳轉(zhuǎn),需要在AndroidManifest.xml中申明activity?
Intent?intent?=?new?Intent(FormStuff.this,?HelloTabWidget.class);?
startActivity(intent);?
}?
});?
}?
復(fù)制代碼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跳轉(zhuǎn)實(shí)現(xiàn)
使用Action跳轉(zhuǎn),如果有一個(gè)程序的 AndroidManifest.xml中的某一個(gè)Activity的IntentFilter段中定義了包含了相同的Action那么這個(gè)Intent 就與這個(gè)目標(biāo)Action匹配。如果這個(gè)IntentFilter段中沒有定義 Type,Category,那么這個(gè) Activity就匹配了。但是如果手機(jī)中有兩個(gè)以上的程序匹配,那么就會(huì)彈出一個(gè)對(duì)話可框來(lái)提示說(shuō)明。
Action的值在Android中有很多預(yù)定義,如果想直接轉(zhuǎn)到你自己定義的Intent接收者,可以在接收者的 IntentFilter中加入一個(gè)自定義的Action值(同時(shí)要設(shè)定 Category值為"android.intent.category.DEFAULT"),在Intent中設(shè)定該值為Intent的 Action,就直接能跳轉(zhuǎn)到自己的Intent接收者中。因?yàn)檫@個(gè)Action在系統(tǒng)中是唯一的。
data/type,可以用Uri來(lái)做為data,比如Uri uri = Uri.parse();
Intent i = new Intent(Intent.ACTION_VIEW,uri);手機(jī)的Intent分發(fā)過(guò)程中,會(huì)根據(jù) 的scheme判斷出數(shù)據(jù)類型type
手機(jī)的Brower則能匹配它,在Brower的Manifest.xml中的IntenFilter中首先有ACTION_VIEW Action,也能處理http:的type。
至于分類Category,一般不要去在Intent中設(shè)置它,如果寫Intent的接收者,就在Manifest.xml的 Activity的 IntentFilter中包含android.category.DEFAULT,這樣所有不設(shè)置 Category(Intent.addCategory(String c);)的Intent都會(huì)與這個(gè)Category匹配。
extras(附加信息),是其它所有附加信息的集合。使用extras可以為組件提供擴(kuò)展信息,比如,如果要執(zhí)行“發(fā)送電子郵件”這個(gè)動(dòng)作,可以將電子郵件的標(biāo)題、正文等保存在extras里,傳給電子郵件發(fā)送組件。
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跳轉(zhuǎn),需要在AndroidManifest.xml中配置action?
Intent?i?=?new?Intent("android.intent.action.mydialog");?
MyEditText.this.startActivity(i);?
return?false;?
}?
};?
}?
復(fù)制代碼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?
!--配置跳轉(zhuǎn)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
文章標(biāo)題:java安卓跳轉(zhuǎn)頁(yè)面代碼 安卓開發(fā)跳轉(zhuǎn)頁(yè)面代碼
轉(zhuǎn)載源于:http://jinyejixie.com/article6/ddcdcig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、面包屑導(dǎo)航、品牌網(wǎng)站制作、網(wǎng)站制作、動(dòng)態(tài)網(wǎng)站、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)