2017/1/30 DialongShow練習

//20170130 劉彥廷
//DialongShow練習

package com.example.user.myapplication39;

import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

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

        AlertDialog.Builder bdr = new AlertDialog.Builder(this);
        bdr.setMessage("交談視窗練習\n"+//加入文字訊息
                 "請按返回鍵關閉交談窗");
        bdr.setTitle("歡迎"); //加入標題
        bdr.setIcon(R.drawable.scissors);     //加入圖示

      //如果是用內建的圖檔是用 bdr.setIcon(android.R.drawable.presence_away);

        bdr.setCancelable(true);
        bdr.show();
    }
}


activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.user.myapplication39.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"

        android:text="@string/textView"
        tools:context=".MainActivity"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="160dp"
        android:id="@+id/textView" />

</RelativeLayout>

strings.xml

<resources>
    <string name="app_name">DialongShow練習(No39)</string>
    <string name="textView">請在按一次返回鍵結束程式</string>
    <string name="nono" />
</resources>


留言

這個網誌中的熱門文章

IOS_Objective-C學習筆記_(陣列 / 可修改陣列 ;字典 / 可修改字典)..

20170122 Radiobutton功能練習 (溫度轉換)

iOS_開發 拿到 Tableview Cell 上的按鈕是哪一個 (Tableview Cell Button)