`

Android学习之contentview

 
阅读更多
今天在尝试一个工程启动指定的layout的时候出现了错误,只是个人的粗心错误,记录下来保留历史

自定义了一个新的layout,在使用的时候才用
setContentView(R.layout.layout);方法设定值,注意内容包括如下:
1.直接给定了int的值,我当时多余了一部,自己取到了Layout,然后传递进入,只有运行的时候提示空指针异常。
2.R.layout.<layout文件>只需要在layout目录下创建文件即可。不可以自己制定layout的ID,然后传递此ID

分享到:
评论

相关推荐

    Android代码-Android-FloatWindow

    uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" 2.二行代码实现自定义弹窗view View contentView = inflater.inflate(R.layout.layout_pop, null); NewFloatMainWindow....

    android获取根View的方法

    地址:http://blog.csdn.net/lloha/article/details/51496172

    ContentView链接Other.

    ContentView链接Other.

    Android代码-这里收集了大家常用的一些Android的模板代码

    EnglishVersion -&gt;_-&gt;:https://github.com/jiang111/awesome-android-tips/blob/master/README-en.md 值得收藏的AS插件 -&gt;_-&gt;:... 例如下拉刷新时,可以在 contentView 上加一层遮罩。 canvas.drawRect(0, mContentVi

    编译注解实现bindView/contentView框架的Demo

    编译注解实现bindView/contentView框架的Demo

    ContentView.swift

    ContentView.swift

    实验一android开发环境搭建与helloworld.pdf

    在MainActivity.java文件中,我们需要继承ActionBarActivity类,Override onCreate方法,设置ContentView,并实现OptionsMenu和OptionsItemSelected方法。 三、Android编程基础 Android编程基础是Android应用开发...

    Android代码-MDDialog

    MDDialog是一款Material Designed风格的Dialog,可以灵活定制其内容以及显示方式,如:可以添加中间的ContentView,可以对ContentView自由的添加代码操作,如添加点击事件等等;对于多个选项风格的dialog,提供了...

    Android代码-SmartKeyboardManager

    增加 OnContentViewScrollListener,在键盘弹出或隐藏时,优雅地滚动你的 ContentView 效果 Download Step 1. Add the JitPack repository to your build file allprojects { repositories { ... maven { url ...

    android带按钮的通知栏

    拆出来的,自己新手弄了好久,也添加了些备注,希望对新手有帮助 ...2)获取远程视图对象(注:Notification的contentView不能为空) 3)设置PendingIntent(来响应各种事件) 4)发起Notification

    ListView显示单列ArrayList_demo

    5. 在 onCreate 方法中进行初始化操作:onCreate 方法是 Activity 的生命周期方法之一,在这个方法中,我们可以进行初始化操作,例如设置 ContentView、获取控件实例等。 扩展知识点 1. ListView 的使用:ListView ...

    Android代码-X2C

    Generally, when writing a page, everyone writes the layout through xml, and loads the xml layout into memory through set contentView or LayoutInflater.from(context).inflate method. advantage Good ...

    Android_Notification详细解读

    * contentView:当通知被显示在状态条上的时候,同时这个被设置的视图被显示 * defaults:指定哪个值要被设置成默认的 * deleteIntent:当用户点击"Clear All Notifications"按钮时删除所有的通知,这个被设置的 ...

    Android代码-一个简单的安卓快速开发框架

    @ContentView(R.layout.activity_main) public class ActivityMain extends BaseFragmentActivity { @ViewInject(R.id.btn) private Button btn; @OnClick({R.id.btn1, R.id.btn2}) public void onClick...

    Android编程之ICS式下拉菜单PopupWindow实现方法详解(附源码下载)

    本文实例讲述了Android编程之ICS式下拉菜单PopupWindow实现方法。分享给大家供大家参考,具体如下: 运行效果截图如下: 右边这个就是下拉菜单啦,看见有的地方叫他 ICS式下拉菜单,哎哟,不错哦! 下面先讲一下...

    Android代码-Intervention

    @Intervene(name = "ContentView", warnAgainst = "setContentView") fun Activity.layout(@LayoutRes layoutRes: Int) { this.setContentView(layoutRes) } @Intervene(name = "ToastIntervention", warnAgains

    Xamarin.Forms.PancakeView:Xamarin.Forms的扩展ContentView,具有圆角,边框,阴影等!

    Xamarin.Forms的扩展ContentView,具有圆角,边框,阴影等! 为什么选择PancakeView? 在很多Xamarin.Forms用户界面工作中,我确实需要一种可用于支持渐变,边框,圆角和阴影的布局/视图。 由于现有的Xamarin....

    Android编程之自定义AlertDialog(退出提示框)用法实例

    本文实例讲述了Android编程自定义AlertDialog(退出提示框)用法,分享给大家供大家参考,具体如下: 有时候我们需要在游戏或应用中用一些符合我们样式的提示框(AlertDialog) 以下是我在开发一个小游戏中总结出来的....

    实现在android的popupwindow中显示listview.docx

    在 Android 中实现_popupwindow_显示_listview_ 在 Android 开发中,PopupWindow 是一个常用的组件,用于显示临时信息或提供用户交互。然而,在 PopupWindow 中显示 ListView 可能会遇到一些问题。本文将介绍如何在...

    Android代码-SlideBack

    将上页ContentView绘制到当前页,侧滑时动画推入推出。(也许挺不错?) 类全面屏返回手势。即刻App的效果(下图)。 本库这里选择了方案3。 预览 即刻App 本库 Demo下载 Demo下载 使用 引用类库 *请...

Global site tag (gtag.js) - Google Analytics