1

Main.java

package com.example.lolo;

 import android.R;
 import android.app.Activity;
 import android.os.Bundle;
 import android.widget.TextView;

 public class Main extends Activity{

TextView symbolOut;
TextView priceOut;
TextView changePercentageOut;

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);`   
            //It says that "main could not be resolved or is not in a field    
       symbolOut = (TextView) findViewById(R.id.stockPriceOutput);` 
            //t also says that stockPriceOutput cannot be resolved or is not in a field        
    }
 }

main.xml

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context=".Splash" >

  <Button
    android:id="@+id/get_quote_button"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:text="Get Quote" />

  <TextView
    android:id="@+id/stockSymbolOutput"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/get_quote_button"
    android:layout_below="@+id/stockPriceOutput"
    android:layout_marginTop="86dp"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

 <TextView
    android:id="@+id/stockPriceOutput"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/get_quote_button"
    android:layout_below="@+id/get_quote_button"
    android:layout_marginTop="18dp"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

 <TextView
    android:id="@+id/stockChangePercentageOutput"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/stockSymbolOutput"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="92dp"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

 </RelativeLayout>

Android マニフェスト

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.example.lolo"
 android:versionCode="1"
 android:versionName="1.0" >

 <uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.lolo.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:label="@string/app_name" android:name=".Main"></activity>
 </application>

 </manifest>`

私はこれを数日間理解しようとしてきたので、どんな助けも大歓迎です

4

1 に答える 1

2

削除する

import android.R;

からMain.java。どういうわけか間違っRてインポートされました。

その後解決できない場合Rは、インポートされたバージョンが次のとおりであることを確認してください。

import com.example.lolo.R;
于 2013-06-30T10:04:54.360 に答える