0
我有一個使用xml的工作自定義操作欄。我想動態更改由於位置而導致的左側圖像。該位置等於switch語句的情況,所以這不是問題。我做錯了什麼?動態更改自定義操作欄上的ImageView源
ImageView universityLogo;
Global global = new Global();
View v2 = View.inflate(this, R.layout.my_action_bar, null);
universityLogo = (ImageView)v2.findViewById(R.id.buttonLeft);
switch(global.getLocation()){
case "33613":
universityLogo.setImageResource(R.drawable.diploma);
}
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(false);
View mActionBarView = getLayoutInflater().inflate(R.layout.my_action_bar, null);
actionBar.setCustomView(mActionBarView);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
}
和XML
<ImageButton
android:id="@+id/buttonRight"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_height="30dp"
android:layout_width="30dp"
android:layout_alignParentRight="true"
android:background="@drawable/location"
/>
<ImageView
android:id="@+id/buttonLeft"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_height="30dp"
android:layout_width="30dp"
android:layout_alignParentLeft="true"
/>
<ImageView
android:id="@+id/logo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/actionbarlogo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
誠實的錯誤,謝謝 –
投票通過那些小於15的信譽記錄投,但不改變公開展示後得分 –
沒問題!!!! –