解决方案 »

  1.   

    一个就够了,主activity中下方一个导航,上面放一个容器,其他页面都显示在这个容器里
      

  2.   

    写一个自定义的view,然后再其他页面用的的时候像引用其他系统控件一样用就可以了
      

  3.   

    能帮忙写下具体点的代码么?
    新手不知道怎么写在layout中把布局布好(R.layout.widget_title),然后定一个类似这样的TitleView,然后在其他页面需要用到这个  导航菜单 的时候 直接  <com.xx.TitleView> </com.xx.TitleView> 
    这样引用public class TitleView extends RelativeLayout {

    //可以在此定义一些interface或者之类的满足不同页面的需求 private void initView(Context context) {
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.widget_title, this); //在这里对 布局文件的 控件 定义相关事件
    }


    }
      

  4.   

    能帮忙写下具体点的代码么?
    新手不知道怎么写在layout中把布局布好(R.layout.widget_title),然后定一个类似这样的TitleView,然后在其他页面需要用到这个  导航菜单 的时候 直接  <com.xx.TitleView> </com.xx.TitleView> 
    这样引用public class TitleView extends RelativeLayout {

    //可以在此定义一些interface或者之类的满足不同页面的需求 private void initView(Context context) {
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.widget_title, this); //在这里对 布局文件的 控件 定义相关事件
    }


    }额
    思路明白了
    但是具体怎么做一点没看懂我建了布局XML
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"  >    
       <TitleView
            android:id="@+id/MEMU_BAR_LINEAR_LAYOUT"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true" >        <ImageButton
                android:id="@+id/HOME_BUTTON"
                android:layout_width="60dip"
                android:layout_height="60dip"
                android:background="#00ffffff"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_home"
                android:contentDescription="@string/HOME_BUTTON" />        <ImageButton
                android:id="@+id/SEARCH_BUTTON"
                android:layout_width="60dip"
                android:layout_height="60dip"
                android:background="#00ffffff"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_search"
                android:contentDescription="@string/SEARCH_BUTTON" />
                 </TitleView> 
    </RelativeLayout>
    然后eclipse  提示
    Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
    Exception details are logged in Window > Show View > Error Log
    The following classes could not be found:
    - TitleView (Fix Build Path, Edit XML)
    这时候我是不是要创建TitleView 类?
      

  5.   

    能帮忙写下具体点的代码么?
    新手不知道怎么写在layout中把布局布好(R.layout.widget_title),然后定一个类似这样的TitleView,然后在其他页面需要用到这个  导航菜单 的时候 直接  <com.xx.TitleView> </com.xx.TitleView> 
    这样引用public class TitleView extends RelativeLayout {

    //可以在此定义一些interface或者之类的满足不同页面的需求 private void initView(Context context) {
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.widget_title, this); //在这里对 布局文件的 控件 定义相关事件
    }


    }额
    思路明白了
    但是具体怎么做一点没看懂我建了布局XML
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"  >    
       <TitleView
            android:id="@+id/MEMU_BAR_LINEAR_LAYOUT"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true" >        <ImageButton
                android:id="@+id/HOME_BUTTON"
                android:layout_width="60dip"
                android:layout_height="60dip"
                android:background="#00ffffff"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_home"
                android:contentDescription="@string/HOME_BUTTON" />        <ImageButton
                android:id="@+id/SEARCH_BUTTON"
                android:layout_width="60dip"
                android:layout_height="60dip"
                android:background="#00ffffff"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_search"
                android:contentDescription="@string/SEARCH_BUTTON" />
                 </TitleView> 
    </RelativeLayout>
    然后eclipse  提示
    Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
    Exception details are logged in Window > Show View > Error Log
    The following classes could not be found:
    - TitleView (Fix Build Path, Edit XML)
    这时候我是不是要创建TitleView 类?能帮忙写下具体点的代码么?
    新手不知道怎么写在layout中把布局布好(R.layout.widget_title),然后定一个类似这样的TitleView,然后在其他页面需要用到这个  导航菜单 的时候 直接  <com.xx.TitleView> </com.xx.TitleView> 
    这样引用public class TitleView extends RelativeLayout {

    //可以在此定义一些interface或者之类的满足不同页面的需求 private void initView(Context context) {
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.widget_title, this); //在这里对 布局文件的 控件 定义相关事件
    }


    }额
    思路明白了
    但是具体怎么做一点没看懂我建了布局XML
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"  >    
       <TitleView
            android:id="@+id/MEMU_BAR_LINEAR_LAYOUT"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true" >        <ImageButton
                android:id="@+id/HOME_BUTTON"
                android:layout_width="60dip"
                android:layout_height="60dip"
                android:background="#00ffffff"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_home"
                android:contentDescription="@string/HOME_BUTTON" />        <ImageButton
                android:id="@+id/SEARCH_BUTTON"
                android:layout_width="60dip"
                android:layout_height="60dip"
                android:background="#00ffffff"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_search"
                android:contentDescription="@string/SEARCH_BUTTON" />
                 </TitleView> 
    </RelativeLayout>
    然后eclipse  提示
    Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
    Exception details are logged in Window > Show View > Error Log
    The following classes could not be found:
    - TitleView (Fix Build Path, Edit XML)
    这时候我是不是要创建TitleView 类?你自定义view的路径引用不对com.xx.TitleView前面的 com.xx.  是你的TitileView所在的package路径,要引用完全 不然会出现 class could not found
      

  6.   

    还有titleView 里面不需要再添加控件之类的了,既然是要 满足       重用        就应该在 TitleView 的layout里面把需要到的控件先布局好。再具体页面用的时候看情况  View.visible或者View.invisible