
一定是我在自定义视图方面缺少一些基础知识,但我不确定是什么.这是一个非常简单的自定义视图程序,还需要什么来使其工作?
(注意:为了这个问题,我将SurfaceVIEw类放在Activity类中.这不是大型应用程序中的情况.我没有在这里显示AndroidManifest.xml文件,但它只是由日食中的巫师.)
这是java:
package com.mypackage;import androID.app.Activity;import androID.content.Context;import androID.os.Bundle;import androID.util.AttributeSet;import androID.util.Log;import androID.vIEw.SurfaceVIEw;public class SimpleCustomVIEwActivity extends Activity {class TheVIEw extends SurfaceVIEw{ private static final String TAG = "TheVIEw"; public TheVIEw(Context context,AttributeSet attrs) { super(context,attrs); Log.i(TAG,"TheVIEw(" + context + "," + attrs + ")"); }} /** Called when the activity is first created. */ @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.simple_layout); TheVIEw v = (TheVIEw) findVIEwByID(R.ID.myvIEw); }} 这是文件res / layout / simple_layout.xml:
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:orIEntation="vertical" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" > <com.mypackage.SimpleCustomVIEw.TheVIEw androID:ID="@+ID/myvIEw" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" /></linearLayout>解决方法 在xml中它应该是:
<com.mypackage.SimpleCustomVIEw.TheVIEw androID:ID="@+ID/myvIEw" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent"> </com.mypackage.SimpleCustomVIEw.TheVIEw>总结
以上是内存溢出为你收集整理的android – SurfaceView和错误膨胀类全部内容,希望文章能够帮你解决android – SurfaceView和错误膨胀类所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)