Android: странный сбой при запуске активности.Чтобы сделать с упорядочением макета XML - PullRequest
2 голосов
/ 21 марта 2012

он сводит меня с ума, и я надеюсь, что кто-то может пролить свет на это для меня.

У меня есть следующий макет XML, повторенный 3 раза в моем файле XML, и все в порядке, пока ... Я не добавляю фоновое изображение с помощью тега <ImageView> и выравниваю указанное изображение с нижней частью SeekBar, Я изменяю @ + id вокруг так, чтобы у imageview был +.Теперь странно то, что я могу сделать это с последней группой макетов, но не с остальными.Я включил два здесь ради космоса.последний работает удовольствие.Это, однако, позволит мне разместить 2-й (то есть в первом листинге ниже (recordBox) непосредственно над панелью поиска, но не над линейным слоем (и я хочу, чтобы он был над TextView, так что сзади), то есть, когда начинаются сбои.Я также попытался снять его с последнего и надеть только этот, но все равно не радость.

Еще одна вещь, которую я только что заметил, я также могу заставить его работать с playBackBox с @ + id на обоихссылки на playBackSeek.

есть идеи?

 <RelativeLayout
       android:id="@+id/recordBox"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_below="@id/intervalBox"
       android:orientation="vertical"
        >
    <ImageView android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:scaleType="fitXY"
      android:src="@drawable/background"    
      android:layout_alignBottom="@+id/recordSeek"
        />    

          <TextView  android:id="@+id/recordHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Record Duration"
            android:gravity="left"
            android:paddingTop="10dp"
            android:layout_marginLeft="70dp"
            android:textColor="#000000"

            />    

           <LinearLayout  android:id="@+id/record2ndBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_below="@id/recordHeader"
            android:layout_alignLeft="@id/recordHeader"
            >
                <EditText
                    android:id="@+id/recordValue"
                    android:layout_width="75dp"
                    android:layout_height="40dp"
                    android:text="50"
                    android:textSize="14sp"
                    android:gravity="center"
                    android:inputType="number" 
                    android:layout_marginRight="10dp" 
                    />    

                <Spinner android:id="@+id/recordType"
                    android:layout_width="140dp"
                    android:layout_height="40dp"
                    android:drawSelectorOnTop="false"
                    android:layout_marginTop="1dp"
                    /> 
            </LinearLayout>  

          <SeekBar android:id="@id/recordSeek"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:max="100"
               android:progress="50"
               android:layout_below="@id/record2ndBox"
               android:layout_alignLeft="@id/recordHeader"
               android:paddingBottom="20dp"
               android:paddingRight="20dp"
           /> 


    </RelativeLayout> 

   <RelativeLayout
       android:id="@+id/playBackBox"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_below="@id/recordBox"

       android:orientation="vertical"
        >


     <ImageView android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:scaleType="fitXY"
      android:src="@drawable/background"    
      android:layout_alignBottom="@+id/playBackSeek"
        />


              <TextView  android:id="@+id/playBackHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Play Back Duration"
            android:gravity="left"
            android:paddingTop="10dp"
            android:layout_marginLeft="70dp"
            android:textColor="#000000"

            />    

           <LinearLayout  android:id="@+id/playBack2ndBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_below="@id/playBackHeader"
            android:layout_alignLeft="@id/playBackHeader"
            >
                <EditText
                    android:id="@+id/playBackValue"
                    android:layout_width="75dp"
                    android:layout_height="40dp"
                    android:text="50"
                    android:textSize="14sp"
                    android:gravity="center"
                    android:inputType="number" 
                    android:layout_marginRight="10dp" 
                    />    

                <Spinner android:id="@+id/playBackType"
                    android:layout_width="140dp"
                    android:layout_height="40dp"
                    android:drawSelectorOnTop="false"
                    android:layout_marginTop="1dp"
                    /> 
            </LinearLayout>  

          <SeekBar android:id="@id/playBackSeek"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:max="100"
               android:progress="50"
               android:layout_below="@id/playBack2ndBox"
               android:layout_alignLeft="@id/playBackHeader"
               android:paddingBottom="20dp"
               android:paddingRight="20dp"
           /> 

    </RelativeLayout>  

А вот дамп ошибки.

    03-21 17:26:26.934: E/AndroidRuntime(621): FATAL EXCEPTION: main
03-21 17:26:26.934: E/AndroidRuntime(621): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mediabar.timelapse/com.mediabar.timelapse.TimeLapseCalculator}: java.lang.ClassCastException: android.widget.Spinner
03-21 17:26:26.934: E/AndroidRuntime(621):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-21 17:26:26.934: E/AndroidRuntime(621):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-21 17:26:26.934: E/AndroidRuntime(621):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-21 17:26:26.934: E/AndroidRuntime(621):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-21 17:26:26.934: E/AndroidRuntime(621):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-21 17:26:26.934: E/AndroidRuntime(621):  at android.os.Looper.loop(Looper.java:123)
03-21 17:26:26.934: E/AndroidRuntime(621):  at android.app.ActivityThread.main(ActivityThread.java:4627)
03-21 17:26:26.934: E/AndroidRuntime(621):  at java.lang.reflect.Method.invokeNative(Native Method)
03-21 17:26:26.934: E/AndroidRuntime(621):  at java.lang.reflect.Method.invoke(Method.java:521)
03-21 17:26:26.934: E/AndroidRuntime(621):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-21 17:26:26.934: E/AndroidRuntime(621):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-21 17:26:26.934: E/AndroidRuntime(621):  at dalvik.system.NativeStart.main(Native Method)
03-21 17:26:26.934: E/AndroidRuntime(621): Caused by: java.lang.ClassCastException: android.widget.Spinner
03-21 17:26:26.934: E/AndroidRuntime(621):  at com.mediabar.timelapse.TimeLapseCalculator.onCreate(TimeLapseCalculator.java:154)
03-21 17:26:26.934: E/AndroidRuntime(621):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-21 17:26:26.934: E/AndroidRuntime(621):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

OnCreate по запросу

   @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); //anim is coming in, going out
        overridePendingTransition(R.anim.pull_right_in, R.anim.push_left_out);
        setContentView(R.layout.calculator);
        HDDResults = (TextView)findViewById(R.id.HDDResults);
        timeResults = (TextView)findViewById(R.id.TimeResults);      
        extraResults = (TextView)findViewById(R.id.ExtraResults);  
        HDDResults.setText("HDD:");
        timeResults.setText("time Results Area:");
        extraResults.setText("Extra Results Area:");

        radioGroup = (RadioGroup) findViewById(R.id.calcBy);
        rb1 = (RadioButton) findViewById(R.id.byInterval);
        rb2 = (RadioButton) findViewById(R.id.byRecord);
        rb3 = (RadioButton) findViewById(R.id.byPlayBack);
        radioGroup.setOnCheckedChangeListener(this);
        intSeek = (SeekBar)findViewById(R.id.intervalSeek);
        intSeek.setOnSeekBarChangeListener(this);
        intTextValue = (EditText)findViewById(R.id.intervalValue);
        intTextValue.setOnFocusChangeListener(this);
        intTextValue.addTextChangedListener(this);

        intType=(Spinner)findViewById(R.id.intervalType); 
        intType.setOnItemSelectedListener(this);
        ArrayAdapter<String> intTypelist=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,intTypeItems);
        intTypelist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        intType.setAdapter(intTypelist); 

        recSeek = (SeekBar)findViewById(R.id.recordSeek);
        recSeek.setOnSeekBarChangeListener(this);
        recTextValue = (EditText)findViewById(R.id.recordValue);
        recTextValue.setOnFocusChangeListener(this);
        recTextValue.addTextChangedListener(this);

        recType=(Spinner)findViewById(R.id.recordType);        
        recType.setOnItemSelectedListener(this);
        ArrayAdapter<String>    recTypelist=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,recTypeItems);        
        recTypelist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);   
        recType.setAdapter(recTypelist);    

        playSeek = (SeekBar)findViewById(R.id.playBackSeek);
        playSeek.setOnSeekBarChangeListener(this);
        playTextValue = (EditText)findViewById(R.id.playBackValue);
        playTextValue.setOnFocusChangeListener(this);
        playTextValue.addTextChangedListener(this);

        playType=(Spinner)findViewById(R.id.playBackType);
        playType.setOnItemSelectedListener(this);   
        ArrayAdapter<String>    playTypelist=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,playTypeItems);              
        playTypelist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);     
        playType.setAdapter(playTypelist);         

    }

1 Ответ

3 голосов
/ 21 марта 2012

Попробуйте проекты> Очистить, если вы находитесь на затмении, которое должно решить все эти проблемы. если нет, перезапустите затмение. У меня была такая проблема, прежде чем кто-то сказал мне, что XML-файл строится на его компонентах. Это может быть перепутано.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...