test Java代码

来源:互联网 发布:项目经理考试软件 编辑:程序博客网 时间:2024/06/06 00:19
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.android.settings;import android.content.ContentResolver;import android.content.Context;import android.media.AudioManager;import android.net.Uri;import android.preference.PreferenceManager;import android.preference.Preference;import android.preference.PreferenceActivity;import android.preference.PreferenceScreen;import android.preference.Preference;import android.util.AttributeSet;import android.content.res.TypedArray;import android.os.Parcel;import android.os.Parcelable;import android.util.Log;import android.view.View;import android.widget.ImageView;;import android.widget.TextView;import android.telephony.TelephonyManager;import android.os.SystemProperties;import android.provider.Settings;import com.android.settings.R;/** A slider preference that directly controls an audio stream volume (no dialog) **/public class DeviceinfoUpdatePreference extends Preference        {    private static final String TAG = "DeviceinfoUpdatePreference";        private static final String TEST_SUBSCRIBER_PROP = "test.subscriberid";       private Context mContext;        private boolean hasUpdate;        private ImageView updateIcon;             public DeviceinfoUpdatePreference(Context context, AttributeSet attrs, int defStyleAttr,            int defStyleRes) {        super(context, attrs, defStyleAttr, defStyleRes);              mContext = context;                      setLayoutResource(R.layout.deviceinfo_update);            }    public DeviceinfoUpdatePreference(Context context, AttributeSet attrs, int defStyleAttr) {        this(context, attrs, defStyleAttr, 0);    }    public DeviceinfoUpdatePreference(Context context, AttributeSet attrs) {        this(context, attrs, 0);    }    public DeviceinfoUpdatePreference(Context context) {        this(context, null);    }        @Override    protected void onBindView(View view) {        super.onBindView(view);         Log.d(TAG,"---onBindView----");                      hasUpdate = Settings.System.getInt(mContext.getContentResolver(), "has_update_package", 0) ==1?true:false;updateIcon = (ImageView)view.findViewById(R.id.update_icon);if(hasUpdate){updateIcon.setVisibility(View.VISIBLE);}else{updateIcon.setVisibility(View.GONE);}    }       public void setUpdateIcon(boolean flag){        Log.d(TAG,"setUpdateIcon-----"+flag);        /*if(flag){updateIcon.setVisibility(View.VISIBLE);}else{updateIcon.setVisibility(View.GONE);}  */hasUpdate = flag;notifyChanged();    }    }

0 0
原创粉丝点击