English 中文(简体)
Newbie Andersrouble: app opening wrong main.xml?
原标题:Newbie Android Trouble: app opening wrong main.xml?

我刚刚开始发展,因此,请与我一道。

我的问题是,在我进行猛烈的屏幕后,当我掌握在主人身上时,登上下台的屏幕与我在座的完全不同。 两种相互冲突的屏幕名称相同(主角xml),因此它们可能与它有某种关系,但它们具有完全不同的组合和工作空间。 我一直在尝试用我的守则,在我猛烈的屏幕后,停止屏幕,彻底显示,因此,我可以更好地了解问题在何地发生,但却没有成功。

是否有任何想法可能错了,或至少应该开始寻求解决这一问题?

<>strong>files in eclipse:https://i.stack.imgur.com/wAKG1.jpg

package com.mwmnj.criticmatch;

import android.app.Activity;
import android.os.Bundle;

public class CriticMatchActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);    
    }
}

main.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" android:padding="20dp"
    android:weightSum="1">
    <TextView android:textAppearance="?android:attr/textAppearanceLarge"
        android:id="@+id/textView1" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Hello!"
        android:layout_gravity="center" />
    <TextView android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/textView2" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="criticmatch">android:layout_gravity="center"></TextView>
    <Button android:text="Proceed" android:layout_width="match_parent"
        android:layout_height="wrap_content" android:id="@+id/button1"
        android:layout_marginTop="50dp" />
</LinearLayout>

Splash class:

package com.mwmnj.criticmatch;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash extends Activity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        Thread timer = new Thread(){
            public void run(){
                try{
                    sleep(5000);
                } catch (InterruptedException e){
                    e.printStackTrace();
                }finally{
                    Intent openStartingPoint = new Intent("matt.meyer.criticmatch.MENU");
                    startActivity(openStartingPoint);
                }
            }
        };
        timer.start();
    }
}

<>strong>splash.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/crbackground"
  >


</LinearLayout>

<>strong>androidmani.4/1999/.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mwmnj.criticmatch"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">

        <activity android:name=".Splash"
                  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=".CriticMatchActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.mwmnj.criticmatch.CRITICMATCHACTIVITY"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>
</manifest>
最佳回答

你的问题是:

Intent openStartingPoint = new Intent("matt.meyer.criticmatch.MENU");
startActivity(openStartingPoint);

就我可以说的话来说,这一点指其他一些意思。 为此:

Intent openStartingPoint = new Intent(Splash.this, CriticMatchActivity.class);
startActivity(openStartingPoint);

Using the action name should work, too, as long as it matches the name in the AndroidManifest.xml:

Intent openStartingPoint = new Intent("com.mwmnj.criticmatch.CRITICMATCHACTIVITY");
问题回答

我的猜测是,在一揽子探索者中,你选择了Eclipse的错误项目。

Either the project or one if its source files should be selected for the laucher to lauch this app. Even if you are currently editing a source from this project.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签