解决方案 »
- 求助 使用webview加载google map api v3以后如何读取当前应用的数据库
- Android UI下拉刷新 手势放大 高清图片异步加载 图片高速缓存 gallery循环滑动
- UC浏览器问题
- 请教EditView的问题
- android下载图片,如何之建立一次连接下载多幅图片,对HTTP协议要有了解。PS:人品好才是真的好,结帖率100%
- android 获取位置为null(附源代码)
- android项目依赖和导入jar包的差别
- Android 的ActionBar 的问题!
- android自定义主题的问题panelMenuListTheme
- 安卓屏幕滑动阈值
- android开发百度地图定位到大西洋去了!!
- 自定义的dialog类,在主窗口的button的OnClick事件被调出来,请问怎么得到dialog的值,有代码,帮改代码!!!
新手不知道怎么写在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); //在这里对 布局文件的 控件 定义相关事件
}
}
新手不知道怎么写在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 类?能帮忙写下具体点的代码么?
新手不知道怎么写在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