findviewbyid

    0熱度

    2回答

    我有一個名爲DataNode的類,它將在AsyncTask內實例化。好吧。 但是,如果任務失敗,我想顯示一個錯誤,如果成功,則顯示一個標題。 所以,裏面的DataNode類我有一個方法稱爲onOk()將由異步調用。 我已經在XML樣式表文件中將標題/錯誤實例化爲不可見,只是想顯示'他們。 我試圖做(在標題爲例): public void onOk(){ TextView view = (

    0熱度

    3回答

    我想了2天解決這個問題。我做了一個片段,我在其中開啓了啓用和禁用藍牙的功能。那麼在我的主要活動我寫道: bluetoothSwitch = (Switch) findViewById(R.id.bluetooth_switch); bluetoothSwitch.setOnClickListener(clicked); 其中點擊: clicked = new ButtonClicked();

    -2熱度

    2回答

    晚上好, 我有一個問題,我想宣佈「finViewById」一次全球。但它只能作爲本地使用,所以我必須複製和粘貼它們,這是不好的。 公共類MainActivity擴展AppCompatActivity { //(I WANT HERE) @Override protected void onCreate(Bundle savedInstanceState) { super.onCrea

    0熱度

    1回答

    我定義了我自己的tableLayout,它擴展了TableLayout。 在我的課堂我試圖創建MyTableLayout對象: int tableLayoutId = R.id.tableLayoutId; MyTableLayout tableLayout = new MyTableLayout(this); tableLayout.createTableLayout(tableLayout

    0熱度

    1回答

    當我試圖在onCreate期間在片段中分配LinearLayout變量時,我得到一個NPE。這個錯誤只發生在API版本< 23(我沒有全部嘗試過,但嘗試過19和16,它們在啓動時崩潰了)。在23以上,一切都很完美,我不知道爲什麼。問題 代碼: public void reset() { layoutHolder = ButterKnife.findById(view, R.id.lay

    0熱度

    3回答

    我有大約50個EditText字段,我想用循環獲取它們的值。獲得如下單獨的值正常工作: SharedPreferences settings = getSharedPreferences(filename, 0); SharedPreferences.Editor editor = settings.edit(); editor.clear(); //not sure if t

    1熱度

    2回答

    我遇到R.java問題。我創建了一個庫,它在Genymotion上完美運行。然後我將庫的aar複製到我的主項目中。主項目在圖書館的代碼中崩潰。 這裏是我的庫代碼: LayoutInflater user = (LayoutInflater)this.mContext.getSystemService("layout_inflater"); convertView = user.inflate(l

    -5熱度

    3回答

    我有一個片段是一半的圖像,然後是一半的文本。 試圖分配ImageView和TextView但它說: 可能給空 ,當我運行的應用程序不運行。 我包含Java和XML文件的片段幷包含mainActivity java。 片段代碼: import android.media.Image; import android.os.Bundle; import android.provider.Contac

    0熱度

    1回答

    我真的很擔心.findViewById()方法及其在自定義複合視圖創建中的使用。我不知道確切的地方,它保證它永遠不會返回null。 比方說,我有這樣的習俗複合視圖,它被添加到一些.xml這樣的: <com.app.path.TwoButtonsView android:id="@+id/ok_cancel_view" android:layout_width="matc

    0熱度

    1回答

    書寫樣板代碼總是困擾我。 Android中的這些東西之一是有約束力的意見: TextView email; TextView password; //... private bindViews() { email = (TextView) findViewById(R.id.email); password = (TextView) findViewById(R.id.