首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Could not create tab content because could not find view with id 2130903042,该怎么处

2013-12-19 
Could not create tab content because could not find view with id 2130903042?xml version1.0 enco

Could not create tab content because could not find view with id 2130903042
<?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent"  
    > 
   
        
        <LinearLayout
            android:id="@+id/LinearLayout01"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >
            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/one"/>"
            
            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="111111111111111111111" />
        </LinearLayout>
        
        <LinearLayout
            android:id="@+id/LinearLayout02"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >
            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/two"/>
            
            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="222222222222222222222" />
        </LinearLayout>
        
        <LinearLayout
            android:id="@+id/LinearLayout03"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="303dp"
                android:layout_height="362dp"
                android:layout_weight="0.35"
                android:src="@drawable/three" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"


                android:layout_height="wrap_content"
                android:text="333333333333333333333" />
        </LinearLayout>

    </FrameLayout>


package com.example.tabhost;

import android.os.Bundle;
import android.app.TabActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.widget.TabHost;

public class MainActivity extends TabActivity {

private TabHost myTabhost;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

myTabhost = this.getTabHost();
LayoutInflater.from(this).inflate(R.layout.activity_main, myTabhost);

myTabhost.addTab(myTabhost.newTabSpec("select1")
.setIndicator("select1", this.getResources().getDrawable(R.drawable.p1))
.setContent(R.id.LinearLayout01));
myTabhost.addTab(myTabhost.newTabSpec("select2")
.setIndicator("select2", this.getResources().getDrawable(R.drawable.p2))
.setContent(R.id.LinearLayout02));
myTabhost.addTab(myTabhost.newTabSpec("select3")
.setIndicator("select3", this.getResources().getDrawable(R.drawable.p3))
.setContent(R.id.LinearLayout03));

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}



}


总是报 Could not create tab content because could not find view with id 2130903042 的错误 FrameLayout android
[解决办法]
.setContent(R.id.LinearLayout01));
不应该是.setContent(R.layout.LinearLayout01));
吗,
还有这一句,
LayoutInflater.from(this).inflate(R.layout.activity_main, myTabhost);
有啥用?
[解决办法]
setContentView(R.layout.main_tab);用这个方法

LayoutInflater.from(this).inflate(R.layout.activity_main, myTabhost);
这是什么东东

热点排行