findviewbyid

    36熱度

    9回答

    任何人都可以幫助我找出什麼可以是這個程序的問題。 在onCreate()方法中,findViewById()對於所有ID都返回null,這會在稍後導致空指針異常。我無法弄清楚爲什麼findViewById()找不到視圖。有什麼建議麼? 這是主代碼: public class MainActivity extends Activity { ViewPager pager; My

    2熱度

    2回答

    好吧,我對java和android編程都很陌生,但我遇到過最令人沮喪的錯誤,我似乎無法找到解決方案。這裏是錯誤的地方。 ​​ 這裏是按鈕本身的XML。 <Button android:id="@+id/button_main" android:layout_width="match_parent" android:layout_height="90dp" a

    0熱度

    4回答

    我在speed = (TextView) findViewById(R.id.speed);中發現錯誤「速度無法解析或者它不是字段」。 我的佈局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

    0熱度

    2回答

    是否有可能在主要Java類中全局地使用findViewById獲取對XML元素(如按鈕)的引用? 我有這麼多的引用,我需要繼續多次調用它們,因爲我不能使用onCreate方法調用的引用。 private long mode; private final Button playBtn = (Button)findViewById(R.id.playBtn); private final Text

    16熱度

    6回答

    我已經編寫了自定義視圖,並且想要在與我的自定義視圖交互之後更新一些其他視圖。 主要佈局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:custom="http://schemas.andro

    0熱度

    1回答

    您好我add_activity.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_heig

    0熱度

    2回答

    我是Android開發的新手,我試圖讓工作變成一個簡單的例子。 當佈局包含片段時,這些片段被誇大,方法findByViewId返回一個NULL指針。我想知道如何避免這種情況。 activity_main.xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="ht

    1熱度

    2回答

    我有一個自定義組件(像信息面板) - LinearLayout中很少textviews的。 我正在使用android註釋。 問題 如果我嘗試使用@AfterViews,則永遠不會調用該方法(問題1)。 問題是當我嘗試設置在東西通過註釋TextView的,即TextView的爲空(問題2).. ,如果我嘗試從另一個類,在那裏我相信Android的註釋工作,我可以很容易並沒有任何問題得到該textVi

    8熱度

    1回答

    我定義了一個視圖,它擴展了RelativeLayout,我想提取其id在layout xml文件中指定的孩子。 在HeaderView.java: 1 package com.example.test; 2 3 public class HeaderView extends RelativeLayout { 4 5 public HeaderV

    2熱度

    1回答

    我已經創建了一個活動,現在我想的eventListener添加到按鈕: 但是當我切換到AddEntryActivity我得到一個SuperNotCalledException()。 任何幫助真的很感激! public class AddEntryActivity extends ActionBarActivity { @Override protected void onCreate(Bun