Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android studio安裝與調試

Android studio安裝與調試

編輯:關於Android編程

1.下載安裝android studio

下載好之後安裝好

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314015881.jpg

 

2.啟動報錯提示

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314015975.jpg

 

1)進入剛安裝的Android Studio目錄下的bin目錄。找到idea.properties文件,用文本編輯器打開。
2)在idea.properties文件末尾添加一行: disable.android.first.run=true ,然後保存文件。
3)關閉Android Studio後重新啟動,便可進入界面。

 

3.進入啟動界面

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314015916.jpg

 

4.新建項目

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314015954.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314015942.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020091.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020098.jpg

 

5.主界面設置模擬器

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020048.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020065.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020087.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020199.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020162.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020189.jpg

 

6.啟動模擬器

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020177.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020263.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020218.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020282.jpg

 

7.修改代碼

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020242.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020231.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020379.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020330.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020365.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020383.jpg

 

注意修改時間設置必須到andriod設備裡

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020424.jpg

 

data-cke-saved-src=https://www.android5.online/Android/UploadFiles_5356/201702/2017022314020454.jpg

 

8.事件和鏈接

/

 

activity_main.xml


mainactivity.java

package com.hm.myapp;


import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;


public class MainActivity extends Activity {

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

        TextView textView2 = (TextView) findViewById(R.id.textView2);
        textView2.setMovementMethod(LinkMovementMethod.getInstance());
        Spanned text = Html.fromHtml(博客主頁:unix21'Blog);
        textView2.setText(text);
    }

    /* ************************************
     *   按鈕的單擊操作處理函數。
     *   下面的函數是一個按鈕單擊的處理函數。
     *   它需要在layout的xml中將按鈕增加一個OnClick的屬性,
     *   並指定它的處理函數。如下
     *
     *   android:onClick=OnMySelfClick
     *
     *   這樣的話,就不用再增加上面那些復雜的代碼了。
     *
     * */
    public void OnMySelfClick(View v)
    {
        final TextView text = (TextView) findViewById(R.id.textView1);
        Date date=new Date();
        DateFormat format=new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);
        String time=format.format(date);
        text.setText(當前時間是: + time);
    }


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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

 

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved