主界面的布局主要是三个按钮,点击按钮即可进行音量和亮度的进度条调节框
package com.example.contentprovidertest;import android.app.Activity;import android.content.ContentResolver;import android.content.ContentValues;import android.content.Context;import android.content.Intent;import android.database.Cursor;import android.graphics.drawable.BitmapDrawable;import android.media.AudioManager;import android.net.Uri;import android.os.Bundle;import android.util.Log;import android.view.Gravity;import android.view.LayoutInflater;import android.view.View;import android.view.View.OnClickListener;import android.view.WindowManager;import android.widget.Button;import android.widget.ImageView;import android.widget.PopupWindow;import android.widget.SeekBar;import android.widget.SeekBar.OnSeekBarChangeListener;public class MainActivity extends Activity implements OnClickListener{ private static final String TAG = "MainActivity"; private ImageView home; private ImageView volume; private ImageView brightness; private VolumePopwindow volumePopwindow; private BrightnessPopwindow brightnessPopwindow; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); initListener(); }private void initView() {// TODO Auto-generated method stubhome=(ImageView) findViewById(R.id.home);volume=(ImageView) findViewById(R.id.volume);brightness=(ImageView) findViewById(R.id.brightness);}private void initListener() {// TODO Auto-generated method stubhome.setOnClickListener(this);volume.setOnClickListener(this);brightness.setOnClickListener(this);}@Overridepublic void onClick(View view) {// TODO Auto-generated method stubswitch (view.getId()) {case R.id.home:Intent intent = new Intent(Intent.ACTION_MAIN);intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent);Log.i(TAG, "home is click");break; case R.id.volume: volumePopwindow = new VolumePopwindow(MainActivity.this); //volumePopwindow.showAtLocation(view,Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); volumePopwindow.showAtLocation(view, Gravity.CENTER_HORIZONTAL, 0, 0); Log.i(TAG, "volume is click"); break; case R.id.brightness: brightnessPopwindow = new BrightnessPopwindow(MainActivity.this); //volumePopwindow.showAtLocation(view,Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); brightnessPopwindow.showAtLocation(view, Gravity.CENTER_HORIZONTAL, 0, 0); Log.i(TAG, "brightness is click"); break;default:break;}} }
评论