1

我在我的程序中使用 DialogPreference,现在我想在使用 DialogPreference单击确定按钮时重定向到网页

Preferences.xml:-

   <com.chr.tatu.sample.friendslist.contacts.TimePickerPreferences
    android:defaultValue=""
    android:key="about"
    android:summary="Summary"
    android:title="Title"
    android:negativeButtonText="@null" />

TimePickerPreferences.java:-

      public class TimePickerPreferences extends DialogPreference
  {
public TimePickerPreferences(Context context, AttributeSet attrs) {
    super(context, attrs);

}

public TimePickerPreferences(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

}
 }
4

1 回答 1

1

试试这个代码:

  @Override
  public void onClick(DialogInterface dialog,
                      int button) {
    if (button == Dialog.BUTTON_POSITIVE) 
    {Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
    myWebLink.setData(Uri.parse("http://www.google.com"));
    startActivity(myWebLink);
    }
}
于 2013-02-15T13:22:01.070 回答