Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
资源$NotFoundException内置Android资源?_Android_Exception_Layout_Resources - Fatal编程技术网

资源$NotFoundException内置Android资源?

资源$NotFoundException内置Android资源?,android,exception,layout,resources,Android,Exception,Layout,Resources,我在eclipse上启动了一个Android项目,并制作了一个简单的加载条,如下所示: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LOG = true; // Initialize a GUI if(LOG) Log.d(TAG, "starting content view and progress bar n

我在eclipse上启动了一个Android项目,并制作了一个简单的加载条,如下所示:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LOG = true;

    // Initialize a GUI
    if(LOG) Log.d(TAG, "starting  content view and progress bar notifications");

    //initialize resource 
    // i put try to check the Exception
    try {
        setContentView(R.layout.load);
        RelativeLayout rl = (RelativeLayout) findViewById(R.id.loading_layout);
        mProgress = (ProgressBar) rl.findViewById(R.id.progressBarLoad);
        mProgressText = (TextView) rl.findViewById(R.id.textProgressLoad);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if(LOG) Log.d(TAG, "bar notifications initialized");
    Thread t = new Thread(new Runnable() {
        public void run() {
            try {
                if(LOG){
                    Log.d(TAG, "starting update "+mProgress.toString());
                    Log.d(TAG, "starting update "+mProgressText.toString());
                }

                while (mProgressStatus<100) {
                    //Do all process here
                    /*
                    if(mProgress % getNumberSubProcess() == 0){

                    }
                    */
                    LoadFEIAppActivity.this.update();
                    mProgressStatus += 0.01d; 
                }

                if(mProgressStatus==100){
                    LoadFEIAppActivity.this.update();
                    if(LOG) Log.d(TAG, "DONE");
                    return;
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    });

    t.start();

    /*
    if(mProgressStatus==100){
        Intent intent = new Intent(this, RegisterEmail.class);
        startActivity(intent);
    } 
     */     
}
@覆盖
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
LOG=真;
//初始化GUI
if(LOG)LOG.d(标记“启动内容视图和进度条通知”);
//初始化资源
//我尝试检查异常
试一试{
setContentView(R.layout.load);
RelativeLayout rl=(RelativeLayout)findViewById(R.id.loading_布局);
mProgress=(ProgressBar)rl.findViewById(R.id.progressBarLoad);
mProgressText=(TextView)rl.findViewById(R.id.textProgressLoad);
}捕获(例外e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
if(LOG)LOG.d(标记“bar通知已初始化”);
线程t=新线程(新的可运行线程(){
公开募捐{
试一试{
如果(日志){
Log.d(标记“开始更新”+mProgress.toString());
Log.d(标记“开始更新”+mProgressText.toString());
}

while(mProgressStatus首先检查您是否有
res/drawable/progress\u undefinite\u horizontal.xml
?然后

progress\u undeterminate\u horizontal.xml
在这个xml中,您的
progressbar
没有某种状态,所以它的问题

查看此链接

文件

res/drawable/progress\u undeterminate\u horizontal.xml

具有项目中不存在的颜色引用

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/progress_indeterminate_horizontal.xml from color state list resource ID #0x1030008

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/progress_indeterminate_horizontal.xml from xml type colorstatelist resource ID #0x1030008
是的,照片的密度会影响编辑,但由于您使用的是res/drawable/这是默认文件夹,并且您的项目中有资源,因此不会影响编辑


发布res/drawable/progress\u undeterminate\u horizontal.xml,如下所示,manifest.xml和有问题的活动中使用的布局:

我的项目中的层次结构树是(与xml文件相关):

  • res/
    • 布局/
      • loading.xml
      • registeremail.xml
    • 可牵引/
      • hdpi/
        • logo.png
        • mulherfeia2012.jpg
      • mdpi/
        • 没什么
      • ldpi/
        • 没什么
我试图运行的
res/layout/loading.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/loading_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ProgressBar
        android:id="@+id/progressBarLoad"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true" />

    <TextView
        android:id="@+id/textProgressLoad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/progressBarLoad"
        android:layout_centerHorizontal="true"
        android:text="@string/loading_message"
        android:textColor="@android:color/white" />
    <ImageView
        android:id="@+id/imageLoad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/progressBarLoad"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/logo_feia_description"
        android:src="@drawable/mulherfeia2012" />
</RelativeLayout>

非常感谢您的帮助!

hi-gcrav发布您的进度\u不确定\u horizontal.xml文件…问题是:我没有创建此文件:p无需放置“已解决”在你的标题中。你已经接受了答案,这就足够了。嗨Jorgesys和Samir,问题是我没有创建
res/drawable/progress\u iderteminate\u horizontal.xml
。我认为这是Android SDK的内置资源(?)这个问题以前没有出现过,只有在我创建另一个活动时才出现。我将在问题布局中发布文件,并声明抱歉,萨米尔,我误解了你的意思(这是中级英语…:P),我将尝试发布againOk@Samir,阅读所有帖子,并“黑客”安卓,我这样做:在文件
res/layout/loading.xml
,这就是有问题的文件,我添加了一个简单的行:
android:progressDrawable=“@android:drawable/progress\u undeterminate\u horizontal”/>
和特定的异常(
InflateException
)dissapears.I现在有其他异常:
E/AndroidRuntime(295):java.lang.RuntimeException:无法实例化应用程序unicamp.ia.feia.fEIApp2012:java.lang.ClassNotFoundException:加载程序dalvik.system中的unicamp.ia.feia.fEIApp2012。PathClassLoader@44e8cdd0
ops,我在元素中添加行;)记住:我没有在任何时候创建文件
res/drawable/progress\u undeterminate\u horizontal.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/loading_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ProgressBar
        android:id="@+id/progressBarLoad"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true" />

    <TextView
        android:id="@+id/textProgressLoad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/progressBarLoad"
        android:layout_centerHorizontal="true"
        android:text="@string/loading_message"
        android:textColor="@android:color/white" />
    <ImageView
        android:id="@+id/imageLoad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/progressBarLoad"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/logo_feia_description"
        android:src="@drawable/mulherfeia2012" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="unicamp.ia.feia"
    android:versionCode="1"
    android:versionName="0.1" >

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7" android:maxSdkVersion="7"/>

<application
    android:icon="@drawable/feia12_logo_low"
    android:label="@string/app_name" 
    android:testOnly="false" 
    android:debuggable="true">
    <activity
        android:name=".LoadFEIAppActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity 
        android:name=".RegisterEmail">
    </activity>
</application>
</manifest>