lundi 11 mai 2015

Android Application run in a real Mobile but not in Eclipse

My application run in my real mobile phone but not in Eclipse+Android Studio Enviroment. I check class and Android Manifest and are same. Whats wrong ?

My codes are:

1) MainActivity.java

package com.example.homework2;

import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;


public class MainActivity extends ActionBarActivity 
{
    EditText firstnameText;
    Button goButton, aboutButton;

    @Override
    protected void onCreate( Bundle savedInstanceState ) 
    {
        super.onCreate( savedInstanceState );       
        setContentView( R.layout.activity_main );       

        //firstnameText = ( EditText ) findViewById( R.id.editText1 );
        //String name = firstnameText.getText().toString();
/*      
        goButton =  ( Button ) findViewById( R.id.letsgo_button );
        goButton.setOnClickListener( new OnClickListener() 
        {
            @Override
            public void onClick( View v ) 
            {
                // TODO Auto-generated method stub
            }
        }); 
*/      
        aboutButton = ( Button ) findViewById( R.id.about_button );
        aboutButton.setOnClickListener( new OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {
                // TODO Auto-generated method stub
                Intent about = new Intent( MainActivity.this, About.class );
                startActivity( about );
            }           
        });
    }
}

2) activity_main.xml

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.homework2.MainActivity" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:scaleType="centerCrop"
        android:src="@drawable/wallpaper1" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="35dp"
        android:paddingTop="16px"
        android:paddingBottom="16px"
        android:background="#2B3856"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Enter your Name: "
        android:textColor="#E8E8E8"
        android:textStyle="bold" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/about_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:background="#101010"
        android:text="About"
        android:textColor="#F8F8F8"
        android:textStyle="bold" />

    <Button
        android:id="@+id/letsgo_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/about_button"
        android:layout_alignLeft="@+id/imageView1"
        android:layout_marginBottom="16dp"
        android:background="#3B0B0B"
        android:text="Let&apos;s GO !!!"
        android:textColor="#E8E8E8"
        android:textStyle="bold" />

</RelativeLayout>

3) About.java

package com.example.homework2;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;

public class About extends ActionBarActivity 
{   
    @Override
    protected void onCreate( Bundle savedInstanceState ) 
    {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.about );
    }
}

4) about.xml

   <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://ift.tt/nIICcg"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >


        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="463dp"
            android:layout_x="1dp"
            android:layout_y="-8dp"
            android:scaleType="centerCrop"
            android:src="@drawable/wallpaper2" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="209dp"
            android:layout_x="-1dp"
            android:layout_y="101dp"
            android:textColor="#FFFFFF"
            android:textStyle="bold|italic"   
            android:ems="10"
            android:gravity="center"
            android:text="Πριν δυο χρόνια ο Σερ Άλεξ Φέργκιουσον σταμάτησε την προπονητική. Η συγκεκριμένη εφαρμογή βάζει ένα κουίζ στους οπαδούς της ομάδας, για τα πεπραγμένα του Σκωτσέζου κόουτς στον πάγκο της Μάντσεστερ Γιουνάιτεντ." >

            <requestFocus />
        </EditText>
    </RelativeLayout>

5) AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
    package="com.example.homework2"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            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=".About"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.homework2.ABOUT" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Aucun commentaire:

Enregistrer un commentaire