私は自分のウェブサイトを読み込むWebviewを持つアプリケーションのために働いていて、私のwebviewのページが読み込まれているときにロードするプログレスバーを持っています。開始方法を確認するには、2つのボタンを作成しようとしました.1つは進行状況の停止バーで、もう1つは開始です。View.INVISIBLEは私のためには機能しませんが、View.GONEは正常に動作します
私の進行状況バーは、アプリケーションの起動時にデフォルトで読み込まれます。 これを止めるボタンとボタンを作成しましたが、これを停止する必要のあるボタンでこれをやめた後に、このボタンをもう一度起動する必要があるボタンは機能しません。 私は、すべてのページでWebviewを持っているので、読み込み開始はWebviewの下に戻ります。開始時にアプリケーションを開く)WebViewを進行状況バー(画面の中央)に移動し、停止ボタンで停止すると画面が終了します。スタートボタンでこれをもう一度開始すると、プログレスバーは表示されませんが、画面の中央までです。 Googleで検索しましたが、何も見つかりません。 私の悪い英語のため申し訳ありませんが、私は唯一のforteen歳だ...
ここに私のxmlコード:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="me.filtering.netsparkmobile.MainActivity"
tools:showIn="@layout/app_bar_main">
<TextView
android:text="!אבה ךורב"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textColor="@color/colorAccent"
android:textSize="@dimen/activity_vertical_margin"
android:id="@+id/textView6" />
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignLeft="@+id/textView6"
android:layout_alignStart="@+id/textView6"
android:id="@+id/progressBar2" />
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="stop progressbar"
android:onClick="stopPB" />
<Button
android:id="@+id/button_send2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start progressbar"
android:onClick="startPB"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
そして、ここに私のJavaコードの一部:
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
ProgressBar PB1;
int ProgressBarStatus=1;
public void stopPB(View arg0) {
ProgressBar PB1 = (ProgressBar) findViewById(R.id.progressBar2);
PB1.setVisibility(View.GONE);
}
public void startPB(View arg0) {
ProgressBar PB1 = (ProgressBar) findViewById(R.id.progressBar2);
PB1.setVisibility(View.INVISIBLE);
}
あなたがView.INVISIBLEを使用する場合、それはどのようなエラーを与えるのでしょうか?また、このアプローチを試してみてください。 progressBar.setVisibility(0); --visible progressBar.setVisibility(4); --invisible progressBar.setVisibility(8); - 解消したように。 –
@HonorLTそれは私に誤りを与えない。それは動作していませんが、エラーを出すことはありません。 progressBar.setVisibility(0);という意味はどういう意味ですか?可能なコマンドではありません。 – Fox