Android 3新特性+源码实现(三)

2014-11-24 10:51:27 ? 作者: ? 浏览: 7
ngeListener() {
@Overridepackage com.jsd.demo;



import android.app.Activity;
import android.os.Bundle;
import android.widget.NumberPicker;
import android.widget.Toast;
import android.widget.NumberPicker.OnValueChangeListener;



public class NumberPickerActivity extends Activity{



private NumberPicker mNp1 = null,mNp2 = null,mNp3 = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.number_picker);
findViewById();
}

private void findViewById(){
mNp1 = (NumberPicker) findViewById(R.id.numberPicker);
mNp1.setLeft(0);
mNp1.setMaxValue(24);
mNp1.setOnValueChangedListener(new OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
Toast.makeText(NumberPickerActivity.this, picker.getValue()+"hours-", 1).show();
}
});
mNp2 = (NumberPicker) findViewById(R.id.numberPicker2);
mNp2.setLeft(0);
mNp2.setMaxValue(60);
mNp2.setOnValueChangedListener(new OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
Toast.makeText(NumberPickerActivity.this, picker.getValue()+"minutes", 1).show();
}
});
mNp3 = (NumberPicker) findViewById(R.id.numberPicker3);
mNp3.setLeft(0);
mNp3.setMaxValue(60);
mNp3.setOnValueChangedListener(new OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
Toast.makeText(NumberPickerActivity.this, picker.getValue()+"seconds", 1).show();
}
});
}
}
public void onSelectedDayChange(CalendarView view, int year, int month,
int dayOfMonth) {
Toast.makeText(CalendarActivity.this, "年:"+year+"-月:"+month+"-日:"+dayOfMonth, 1).show();

}
});
}
}




package com.jsd.demo;



import java.io.InputStream;



import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;



public class NotificationActvity extends Activity{



private NotificationManager nm = null;
private Notification.Builder build = null;
private Notification n;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.notifactions);
findViewById();
}

private void findViewById(){
Button notifications = (Button) findViewById(R.id.notifications);
nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
build = new Notification.Builder(NotificationActvity.this);
build.setDefaults(Notification.DEFAULT_SOUND);
build.setAutoCancel(true);
build.setContentTitle("title");
build.setContentText("this is for message!");
InputStream is = getResources().openRawResource(R.drawable.icon);
Bitmap bitmap = new BitmapDrawable(is).getBitmap();
build.setLargeIcon(bitmap);
// build.setSmallIcon(R.drawable.icon);
Intent it = new Intent(this,PopMenuActivity.class);
Pe

-->

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: