菜鸟求助android中activity的注册问题

KevinzXiao 2012-06-02 01:00:32
[code=Java]代码如下:
第一个Activity:
package com.shao.Activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Activity02 extends Activity {
/** Called when the activity is first created. */
private Button myButton=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myButton = (Button)findViewById(R.id.myButton);
myButton.setText(R.string.Button);
myButton.setOnClickListener(new MyButtonListener());
}
class MyButtonListener implements OnClickListener{

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(Activity02.this, OtherActivity.class);
Activity02.this.startActivity(intent);

}


}
}
第二个Activity:
package com.shao.Activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class OtherActivity extends Activity{
private TextView myTextView=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.other);
myTextView=(TextView)findViewById(R.id.myTextView);
myTextView.setText(R.string.other);
}

}
AndroidManifest代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shao.Activity"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="7"
android:targetSdkVersion="8"/>


<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".Activity02"
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=".OtherActivity" android:label="@string/other"/>
</application>

</manifest>
...全文
186 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 的回复:]

问题很明显:
Error inflating class Textiew

单词拼写错误Textiew -> TextView
[/Quote]
+
ngf318 2012-06-04
  • 打赏
  • 举报
回复
问题很明显:
Error inflating class Textiew

单词拼写错误Textiew -> TextView
rhb 2012-06-03
  • 打赏
  • 举报
回复
请看这一行 Binary XML file line #7: Error inflating class Textiew和这一行06-03 01:38:38.128: E/AndroidRuntime(390): at com.shao.Activity.OtherActivity.onCreate(OtherActivity.java:13)
应该是R.layout.other这个XML文件有问题
KevinzXiao 2012-06-03
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]
1、建议R.layout.other代码上来;
2、建议将详细报错Log发上来。
[/Quote]
06-03 01:38:38.079: D/AndroidRuntime(390): Shutting down VM
06-03 01:38:38.089: W/dalvikvm(390): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-03 01:38:38.128: E/AndroidRuntime(390): FATAL EXCEPTION: main
06-03 01:38:38.128: E/AndroidRuntime(390): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shao.Activity/com.shao.Activity.OtherActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class Textiew
06-03 01:38:38.128: E/AndroidRuntime(390): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.os.Handler.dispatchMessage(Handler.java:99)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.os.Looper.loop(Looper.java:123)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-03 01:38:38.128: E/AndroidRuntime(390): at java.lang.reflect.Method.invokeNative(Native Method)
06-03 01:38:38.128: E/AndroidRuntime(390): at java.lang.reflect.Method.invoke(Method.java:521)
06-03 01:38:38.128: E/AndroidRuntime(390): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-03 01:38:38.128: E/AndroidRuntime(390): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-03 01:38:38.128: E/AndroidRuntime(390): at dalvik.system.NativeStart.main(Native Method)
06-03 01:38:38.128: E/AndroidRuntime(390): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class Textiew
06-03 01:38:38.128: E/AndroidRuntime(390): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-03 01:38:38.128: E/AndroidRuntime(390): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.app.Activity.setContentView(Activity.java:1647)
06-03 01:38:38.128: E/AndroidRuntime(390): at com.shao.Activity.OtherActivity.onCreate(OtherActivity.java:13)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-03 01:38:38.128: E/AndroidRuntime(390): ... 11 more
06-03 01:38:38.128: E/AndroidRuntime(390): Caused by: java.lang.ClassNotFoundException: android.view.Textiew in loader dalvik.system.PathClassLoader[/data/app/com.shao.Activity-2.apk]
06-03 01:38:38.128: E/AndroidRuntime(390): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
06-03 01:38:38.128: E/AndroidRuntime(390): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
06-03 01:38:38.128: E/AndroidRuntime(390): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
06-03 01:38:38.128: E/AndroidRuntime(390): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-03 01:38:38.128: E/AndroidRuntime(390): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
06-03 01:38:38.128: E/AndroidRuntime(390): ... 20 more
KevinzXiao 2012-06-03
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]
1、建议R.layout.other代码上来;
2、建议将详细报错Log发上来。
[/Quote]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<Textiew
android:id="@+id/myTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>

</LinearLayout>
AMinfo 2012-06-02
  • 打赏
  • 举报
回复
1、建议R.layout.other代码上来;
2、建议将详细报错Log发上来。
KevinzXiao 2012-06-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
android:label="@string/other"/ 你在value的XML文件里面写other了吗,然后你的问题具体是什么呢?
[/Quote]写了 问题就是不能切换到另一个Activity点击按钮就会结束进程
KevinzXiao 2012-06-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
是什么问题?
[/Quote]就是不能切换到另一个Activity点击按钮就会结束进程
Yans 2012-06-02
  • 打赏
  • 举报
回复
android:label="@string/other"/ 你在value的XML文件里面写other了吗,然后你的问题具体是什么呢?
AMinfo 2012-06-02
  • 打赏
  • 举报
回复
是什么问题?

80,493

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧