編輯:關於android開發
package com.example.mvp;
import cn.ljuns.temperature.view.TemperatureView;
import presenter.ILoginPresenter;
import presenter.LoginPresenterCompl;
import android.os.Bundle;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.PopupWindow;
import android.widget.RemoteViews;
import android.widget.Toast;
import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.content.Intent;
public class MainActivity extends Activity implements ILoginView{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
Notification notification = new Notification();
//設置圖標,後面的自定義布局的圖片會覆蓋它,但還是得設置,不然不會顯示到通知欄
notification.icon = R.drawable.ic_launcher;
notification.tickerText = "hello I am gougou";
notification.when = System.currentTimeMillis();
notification.flags = Notification.FLAG_AUTO_CANCEL;
//傳入當前項目的包名,和你通知欄上要顯示的自定義布局的ID
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.activity_amain);
//下面都是設置通知欄布局裡面控件的屬性
remoteViews.setImageViewResource(R.id.imageView1, R.drawable.hot);
remoteViews.setTextColor(R.id.textView1, Color.RED);
remoteViews.setTextViewText(R.id.textView1, "hello I am 小籃子");
remoteViews.setTextViewTextSize(R.id.textView1, 1, 15);
// PendingIntent有4種flag.
// - FLAG_ONE_SHOT 只執行一次
// - FLAG_NO_CREATE 若描述的Intent不存在則返回NULL值
// - FLAG_CANCEL_CURRENT 如果描述的PendingIntent已經存在,則在產生新的Intent之前會先取消掉當前的
// - FLAG_UPDATE_CURRENT 總是執行,這個flag用的最多
PendingIntent pendingIntent = PendingIntent.getActivity(
this, 0, new Intent(this,AMainActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.textView1, pendingIntent);
notification.contentView = remoteViews;
notification.contentIntent = pendingIntent;
NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(1, notification);
}
R.layout.activity_amain 的布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AMainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:clickable="true"
/>
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
/>
</LinearLayout>
自定義可點擊的ImageSpan並在TextView中內置“View“,imagespantextview有的時候可能想在TextView中添加一些圖片,比如下圖,發短信
運用安卓CreateOptionsMenu和onCreateContextMenu菜單,模擬微信聊天界面長按彈出菜單選項。,oncreateoptionsmenu 1
Android學習之Image操作及時間日期選擇器,android選擇器一、基礎學習 1.ImageView是圖片容器,就相當於RadioGroup是RadioButt
(轉)android底部彈出iOS7風格對話選項框(QQ對話框)--第三方開源--IOS_Dialog_Library,android刷ios7本文轉載於:http://