android – SurfaceView和错误膨胀类

概述我试图用自定义视图创建一个应用程序,并且我不断收到“错误膨胀类”. 一定是我在自定义视图方面缺少一些基础知识,但我不确定是什么.这是一个非常简单的自定义视图程序,还需要什么来使其工作? (注意:为了这个问题,我将SurfaceView类放在Activity类中.这不是大型应用程序中的情况.我没有在这里显示AndroidManifest.xml文件,但它只是由日食中的巫师.) 这是java: pac 我试图用自定义视图创建一个应用程序,并且我不断收到“错误膨胀类”.
一定是我在自定义视图方面缺少一些基础知识,但我不确定是什么.这是一个非常简单的自定义视图程序,还需要什么来使其工作?

(注意:为了这个问题,我将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和错误膨胀类所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1129620.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存