初学页面跳转遇到问题求救 安卓 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是Factivity,也急速hi第一个页面的Java代码,另外说下这些代码都没有报错啊package com.exaple.tiaozhuan;import android.app.Activity;import android.content.Context;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class FActivity extends Activity{ private Button bt1; private Context mContext; protected void onCreat (Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.factivity); bt1=(Button)findViewById(R.id.button1_first); /* * 通过点击bt1实现页面之间的跳转 *1.startActivity方式实现 *1》初始化intent */ bt1.setOnClickListener(new OnClickListener( ){ //注册点击事件 @SuppressWarnings("unused") public void onClickListener(View v) { Intent intent=new Intent(mContext,SActivity.class); /* * 第一个参数:上下文对象this * 第二个对象:目标文件 */ startActivity(intent); } @Override public void onClick(View arg0) { // TODO Auto-generated method stub } }); }} 这是第二个界面也就是要跳到的那个。。没哟什么内容的package com.exaple.tiaozhuan;import android.app.Activity;import android.os.Bundle;public class SActivity extends Activity{ protected void onCreat(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sactivity); }} 这是manifest的代码<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.exaple.tiaozhuan" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.exaple.tiaozhuan.FActivity" 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 android:name="com.exaple.tiaozhuan.SActivity"> </activity> </application></manifest> 代码错了吧,首先你的代码中 Intent intent=new Intent(mContext,SActivity.class);/* * 第一个参数:上下文对象this * 第二个对象:目标文件 */startActivity(intent);在 onClick 的外层,你使用的 IDE对这种情况没有报错吗?你直接是在一个内部类的内层直接调用方法的,第二你发的时候最好发一下你的布局文件 放到里面还会有错,刚才想放xml的,系统说不能连续发三个回帖我放在楼下啦 第二个也就是要跳转到的那个页面的布局<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/ermian" /></LinearLayout> 第一个页面的布局<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:id="@+id/button1_first" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/diyi" /> <Button android:id="@+id/button2_second" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/dier" /> <TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/wenben" /></LinearLayout> 你先把Intent intent=new Intent(mContext,SActivity.class);/* * 第一个参数:上下文对象this * 第二个对象:目标文件 */startActivity(intent);放到 onClick(v)里,然后把 onClickListener 方法删掉吧.另外想问下你,你的具体情况是什么,是第一个界面能显示,点击按钮后跳转到第二个界面不显示,还是第一个界面也没法显示 ....看到了,你的 onCreate的名字竟然是 onCreat 少了一个 e,系统没有识别出正确的入口 可以了么,我看了一下你的第一个activity,Intent intent=new Intent(mContext,SActivity.class);mcontext好像没有初始化 bt1.setOnClickListener(new VIew.OnClickListener( ){ //注册点击事件public void onClick(View v) {Intent intent=new Intent(mContext,SActivity.class);/* * 第一个参数:上下文对象this * 第二个对象:目标文件 */startActivity(intent);} 关于自定义属性在jar包的实现 怎么保护android游戏中的图片资源 求助在SurfaceView中使用drawText的问题 请教一个很基本的问题,open xml declaration android系统的编译 安卓系统,图片3D效果化单子,高手的进来 资源回收问题 ■★Android流行的浏览器的区别■★ 给一个思路 当RelativeLayout没有addView时,没有显示出来? 求助~!灯光与物体颜色 急急急急如何判断两个rect是否重合
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;public class FActivity extends Activity{
private Button bt1;
private Context mContext;
protected void onCreat (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.factivity);
bt1=(Button)findViewById(R.id.button1_first);
/*
* 通过点击bt1实现页面之间的跳转
*1.startActivity方式实现
*1》初始化intent
*/
bt1.setOnClickListener(new OnClickListener( ){ //注册点击事件
@SuppressWarnings("unused")
public void onClickListener(View v) {
Intent intent=new Intent(mContext,SActivity.class);
/*
* 第一个参数:上下文对象this
* 第二个对象:目标文件
*/
startActivity(intent);
} @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
});
}
}
import android.os.Bundle;public class SActivity extends Activity{
protected void onCreat(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sactivity);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exaple.tiaozhuan"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.exaple.tiaozhuan.FActivity"
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
android:name="com.exaple.tiaozhuan.SActivity">
</activity>
</application></manifest>
/*
* 第一个参数:上下文对象this
* 第二个对象:目标文件
*/
startActivity(intent);在 onClick 的外层,你使用的 IDE对这种情况没有报错吗?你直接是在一个内部类的内层直接调用方法的,第二你发的时候最好发一下你的布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" /> <TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ermian" /></LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:id="@+id/button1_first"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/diyi" /> <Button
android:id="@+id/button2_second"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dier" /> <TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/wenben" /></LinearLayout>
/*
* 第一个参数:上下文对象this
* 第二个对象:目标文件
*/
startActivity(intent);放到 onClick(v)里,然后把 onClickListener 方法删掉吧.另外想问下你,你的具体情况是什么,是第一个界面能显示,点击按钮后跳转到第二个界面不显示,还是第一个界面也没法显示
Intent intent=new Intent(mContext,SActivity.class);
/*
* 第一个参数:上下文对象this
* 第二个对象:目标文件
*/
startActivity(intent);
}