編輯:關於Android編程
1.3 App類控件
MainActivity.java
[java]
package com.example.apppalettesdemo;
import andro
id.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.my_options_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
Boolean flag = false;
switch (item.getItemId()) {
case R.id.AlertDialog01:
Builder dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("Hint");
dialog.setMessage("This is Message!");
dialog.setPositiveButton("Ok", this);
dialog.show();
flag = true;
break;
case R.id.notificationManager01:
NotificationManager notiManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notiInst = new Notification(
R.drawable.ic_launcher, "This is notify 2012-09-12",
System.currentTimeMillis());
PendingIntent pendIntent = PendingIntent.getActivity(
this, 0, new Intent(this, MainActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
notiInst.setLatestEventInfo(this, "Notify", "Notify 01", pendIntent);
notiManager.notify(0, notiInst);
flag = true;
break;
case R.id.progressDialog01:
ProgressDialog progrDialog = new ProgressDialog(this);
progrDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progrDialog.setMessage("Loading Information...");
progrDialog.show();
flag = true;
break;
default:
break;
}
return flag;
}
// DialogInterface
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(this, "You just press 'AlertDialog' button!", Toast.LENGTH_SHORT).show();
}
}
package com.example.apppalettesdemo;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.my_options_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
Boolean flag = false;
switch (item.getItemId()) {
case R.id.AlertDialog01:
Builder dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("Hint");
dialog.setMessage("This is Message!");
dialog.setPositiveButton("Ok", this);
dialog.show();
flag = true;
break;
case R.id.notificationManager01:
NotificationManager notiManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notiInst = new Notification(
R.drawable.ic_launcher, "This is notify 2012-09-12",
System.currentTimeMillis());
PendingIntent pendIntent = PendingIntent.getActivity(
this, 0, new Intent(this, MainActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
notiInst.setLatestEventInfo(this, "Notify", "Notify 01", pendIntent);
notiManager.notify(0, notiInst);
flag = true;
break;
case R.id.progressDialog01:
ProgressDialog progrDialog = new ProgressDialog(this);
progrDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progrDialog.setMessage("Loading Information...");
progrDialog.show();
flag = true;
break;
default:
break;
}
return flag;
}
// DialogInterface
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(this, "You just press 'AlertDialog' button!", Toast.LENGTH_SHORT).show();
}
}
什麼是AIDLaidl是 Android Interface definition language的縮寫,也就是安卓接口定義語言為什麼要有AIDLAIDL允許你定義客戶
先上預覽圖:流程1.一個勻速圓周運動的點 2.多個勻速圓周運動的點 3.多個圓周運動的點,速度由快到慢 4.點與點之間的間距線性減少,動畫的最後合為一個點 5.為了讓動畫
今天學習了新的功能那就是滑動刪除數據。先看一下效果我想這個效果大家都很熟悉吧。是不是在qq上看見過這個效果。俗話說好記性不如賴筆頭,為了我的以後,為了跟我一樣自學的小伙伴
由於Android項目開源所致,市面上出現了N多安卓軟件市場。為了讓我們開發的軟件有更多的用戶使用,我們需要向N多市場發布,軟件升級後,我們也必須到安卓市場上進行更新,給