1

开始活动时,我正在检索以下错误:

02-14 09:51:30.898: V/ViolazioniActivity(7510): onCreate before 2130903076
02-14 09:51:30.913: D/dalvikvm(7510): DexOpt: couldn't find static field Lit/helian/violazioni/R$id;.btn1
02-14 09:51:30.913: W/dalvikvm(7510): VFY: unable to resolve static field 6831 (btn1) in Lit/helian/violazioni/R$id;
02-14 09:51:30.913: D/dalvikvm(7510): VFY: replacing opcode 0x60 at 0x0015
02-14 09:51:30.913: D/dalvikvm(7510): DexOpt: couldn't find static field Lit/helian/violazioni/R$id;.btn2
02-14 09:51:30.913: I/dalvikvm(7510): DexOpt: unable to optimize static field ref 0x1ab0 at 0x30 in Lit/helian/violazioni/fe/ui/ViolazioniDashboardFragment;.onCreateView
    02-13 18:14:32.565: E/AndroidRuntime(26290): FATAL EXCEPTION: main
    02-13 18:14:32.565: E/AndroidRuntime(26290): java.lang.NoSuchFieldError: it.helian.violazioni.R$id.btn1
    02-13 18:14:32.565: E/AndroidRuntime(26290):    at it.helian.violazioni.fe.ui.ViolazioniDashboardFragment.onCreateView(ViolazioniDashboardFragment.java:38)
    02-13 18:14:32.565: E/AndroidRuntime(26290):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:846)
    02-13 18:14:32.565: E/AndroidRuntime(26290):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
    02-13 18:14:32.565: E/AndroidRuntime(26290):    at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1160)
    02-13 18:14:32.565: E/AndroidRuntime(26290):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
    02-13 18:14:32.565: E/AndroidRuntime(26290):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)

主要活动

    package it.helian.violazioni.be.activity;

import it.helian.violazioni.R;
import android.os.Bundle;
import android.util.Log;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.googlecode.androidannotations.annotations.EActivity;

//@EActivity(resName="activity_violazioni")
@EActivity
public class ViolazioniActivity extends SherlockFragmentActivity {

    public static final String TAG = "ViolazioniActivity";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        Log.v(TAG, "onCreate before " + R.layout.activity_violazioni);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_violazioni);
        Log.v(TAG, "onCreate after");
    }
}

R.layout.activity_violazioni

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<fragment
    android:id="@+id/fragment_dashboardz"
    android:name="it.helian.violazioni.fe.ui.ViolazioniDashboardFragment"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1" />

it.helian.violazioni.fe.ui.ViolazioniDashboardFragment

public class ViolazioniDashboardFragment extends SherlockFragment {
        @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        System.out.println("Check 2a");
        View root = inflater.inflate(R.layout.main_menu, container);
        System.out.println("Check 2b");
        btn1 = (MainButton) root.findViewById(R.id.btn1);
        System.out.println("Check 3");
        btn1.setOnClickListener(
                new View.OnClickListener() {
                    public void onClick(View view) {
                        fireTrackerEvent(EVENT_CLICK_CLASSICA);
                    }

                });

        btn2 =(MainButton) root.findViewById(R.id.btn2);
        btn2.setOnClickListener(
                new View.OnClickListener() {
                    public void onClick(View view) {
                        fireTrackerEvent(EVENT_CLICK_CLASSICA_ANPR);
                    }
                });
}

main_menu.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="1dp"
android:weightSum="101" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="10" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="27"
    android:orientation="horizontal"
    android:weightSum="10" >

    <it.helian.violazioni.fe.ui.MainButton
        android:id="@+id/btn1"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_margin="1dp"
        android:layout_weight="5" />

    <it.helian.violazioni.fe.ui.MainButton
        android:id="@+id/btn2"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_margin="1dp"
        android:layout_weight="5" />
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="10" />

如果您需要更多详细信息,请写下来,我会尽力帮助您!

先感谢您

问候,

卢卡

4

0 回答 0