我想在處理請求時用progressBar替換圖像按鈕。如何在等待請求時用progressBar替換imageButton?
這裏是我的XML
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/gap_normal"
android:orientation="horizontal"
android:background="0000000000">
<com.devspark.robototextview.widget.RobotoTextView
android:id="@+id/conference_text_lockstate"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/gap_normal"
android:layout_marginBottom="@dimen/gap_normal"
android:gravity="left"
android:textSize="@dimen/textsize_normal"
android:paddingRight="@dimen/gap_large"
android:text="Unlocked. When all participants have joined, lock the conference by tapping the padlock."
app:typeface="roboto_condensed_regular" />
<ImageButton
android:id="@+id/conference_checkableimagebutton_lockstate"
android:layout_width="60dp"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:background="@android:color/white"
android:src="@drawable/conference_checkableimagebutton_lockstate_src"
android:cropToPadding="false"/>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/pb"
android:indeterminate="true"
android:visibility="invisible"
/>
</LinearLayout>
,我嘗試與進度在onclick方法來交換圖像按鈕。
if (mLockCheckableImageButton.isChecked()==true){
mLockCheckableImageButton.setClickable(false);
ProgressBar pb = (ProgressBar)inflated.findViewById(R.id.pb);
pb.setVisibility(View.VISIBLE);
//more code here.
但是,這增加了他們旁邊的彼此。任何人?先謝謝你。
使用相對或框架佈局... –
如果你只是想更換,然後forgott調用mLockCheckableImageButton.setVisibility(View.GONE); – Opiatefuchs