0

最後にファイルの内容を表示するので、「Style.xml」を使用したいコードがあります。私がやりたいのは、「Style.xmlで定義される色を変更するProgressDailogインジケーター....シンプルです。

パブリッククラスSimpleProgressDialogはDialog{を拡張します

public static SimpleProgressDialog show(Context context, CharSequence title,
        CharSequence message) {
    return show(context, title, message, false);
}

public static SimpleProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate) {
    return show(context, title, message, indeterminate, false, null);
}

public static SimpleProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate, boolean cancelable) {
    return show(context, title, message, indeterminate, cancelable, null);
}

public static SimpleProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate,
        boolean cancelable, OnCancelListener cancelListener) {
    SimpleProgressDialog dialog = new SimpleProgressDialog(context);
    dialog.setTitle(title);
    dialog.setCancelable(cancelable);
    dialog.setOnCancelListener(cancelListener);
    /* The next line will add the ProgressBar to the dialog. */
    dialog.addContentView(new ProgressBar ( context , null ,android.R.attr.progressBarStyleLargeInverse ), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    dialog.show();

    return dialog;
}

public SimpleProgressDialog(Context context) {
    super(context, R.style.NewDialog);
}   

}

ここにスタイルがあります。style.xmlだけを変更したい

<?xml version="1.0" encoding="utf-8"?>

<resources>
  <!-- The style for the unit on the statistics activity. -->
<style name="NewDialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTitleStyle">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">@android:color/transparent</item>
</style>

4

1 に答える 1

1

ProgressBar何を求めているのかが完全には明確ではありませんが、独自のXMLレイアウトに定義を配置することを強くお勧めします。そこから、属性を追加することでスタイルを簡単に適用できますstyle="@style/NewDialog"

例えば。作成progress.xml

<?xml version="1.0" encoding="utf-8"?>
<ProgressBar
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:id="@+id/progress"
  style="@style/NewDialog"
  >
</ProgressBar>

次に、コードで次のようにします。

dialog.setContentView(R.layout.progres);
于 2011-06-02T19:57:03.677 に答える