android-清單小檔案

來源:互聯網
上載者:User

標籤:android

一:如何創造一個activity

懶得打字了,直接

650) this.width=650;" src="https://s4.51cto.com/oss/201711/11/10e2c728ad0157090d2a28c3887a670c.png-wh_500x0-wm_3-wmp_4-s_3866123293.png" style="float:none;" title="QQ圖片20171111160258.png" alt="10e2c728ad0157090d2a28c3887a670c.png-wh_" />

650) this.width=650;" src="https://s3.51cto.com/oss/201711/11/9dbb31468a01a56997b101da257fdcf7.png-wh_500x0-wm_3-wmp_4-s_764684516.png" style="float:none;" title="QQ圖片20171111160319.png" alt="9dbb31468a01a56997b101da257fdcf7.png-wh_" />

先這樣,其中testactivity代碼如下

package com.example.qingdan;


import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;


public class MainActivity extends Activity {


@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.main, menu);

return true;

}


}

activity_test.xml中如下

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

    <TextView 

        android:layout_width="match_parent"

    android:layout_height="wrap_content"

    android:text="wo shi test"

        />


</LinearLayout>

我們運行一下這個檔案,,發現顯示的還是helloworld

這是什麼原因呢

   <activity

            android:name="com.example.qingdan.MainActivity"

            android:label="@string/app_name" >

            《!----》主入口》

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

如上:

但是怎麼修改呢

在修改之前,我們須知的是

android 四大組件都需要在android中配置

650) this.width=650;" src="https://s5.51cto.com/oss/201711/11/31b56bf42f953efb515b926b3927a31e.png-wh_500x0-wm_3-wmp_4-s_1814507850.png" title="QQ圖片20171111161331.png" alt="31b56bf42f953efb515b926b3927a31e.png-wh_" />

如果不會配置,直接複製粘貼也行哈

但是其中有兩個入口怎麼辦呢

那行,我們就讓他有兩個入口

運行後怎麼辦呢

還是helloworld,會不會出錯了呀,我們這個時候退回看菜單650) this.width=650;" src="https://s1.51cto.com/oss/201711/11/a77ee292d366536433cf2e2ebe8e1a2a.png-wh_500x0-wm_3-wmp_4-s_3096167113.png" title="QQ圖片20171111162006.png" alt="a77ee292d366536433cf2e2ebe8e1a2a.png-wh_" />

出現兩個清單小檔案,

那麼在其中所調用的是哪個嘍

答:是這個。

android:label="@string/app_name" >

原來是這個

那麼我們該怎麼做呢

改一下就行

650) this.width=650;" src="https://s1.51cto.com/oss/201711/11/0bf490212e3398adaa03e0126e83e053.png-wh_500x0-wm_3-wmp_4-s_4091810641.png" title="QQ圖片20171111163508.png" alt="0bf490212e3398adaa03e0126e83e053.png-wh_" />

再顯示即可

我們接下來玩個好玩的,如何給自己的APP配置上自己喜歡的圖片,他有兩個步驟

第一個步驟:找百度找到自己喜歡的圖片

第二個步驟:將圖片配置上去(壞笑)

筆者先去找圖片

。。。。。

。。。。。

。。。。。

好了,找到了,優酷的娘化版,和一張我的部落格首圖

650) this.width=650;" src="https://s3.51cto.com/oss/201711/11/f37bbd593977d4718aa88689216cbb71.jpg-wh_500x0-wm_3-wmp_4-s_1561481654.jpg" style="float:left;" title="下載.jpg" alt="f37bbd593977d4718aa88689216cbb71.jpg-wh_" />
















650) this.width=650;" src="https://s3.51cto.com/oss/201711/11/737421ee71336eb2f292887a7cbe5687.jpg-wh_500x0-wm_3-wmp_4-s_1974761596.jpg" title="眉間雪.jpg" alt="737421ee71336eb2f292887a7cbe5687.jpg-wh_" />

我們就用這個來做,我們APP的映像吧

把他複製,放到

650) this.width=650;" src="https://s1.51cto.com/oss/201711/11/4f6c1282650c07857bd19b4b20faadf3.png-wh_500x0-wm_3-wmp_4-s_1154277688.png" style="float:none;" title="QQ圖片20171111170311.png" alt="4f6c1282650c07857bd19b4b20faadf3.png-wh_" />

然後代碼是這樣的

比以前需要在activity中加入

650) this.width=650;" src="https://s3.51cto.com/oss/201711/11/118541c560be2eb20834c7e68d76b861.png-wh_500x0-wm_3-wmp_4-s_4212742796.png" title="QQ圖片20171111171411.png" alt="118541c560be2eb20834c7e68d76b861.png-wh_" />

因為模擬器太卡了,所以兄弟我玩兒的是真機測試,

好玩兒吧,優酷娘就這樣變成你的APP映像

650) this.width=650;" src="https://s3.51cto.com/oss/201711/11/19fd4a9d0ba20bb0abd02d306b1a84b0.png-wh_500x0-wm_3-wmp_4-s_2535909092.png" title="QQ圖片20171111170148.png" style="float:none;" alt="19fd4a9d0ba20bb0abd02d306b1a84b0.png-wh_" />

還要有一個需要注意的是

這樣可能會一下子產生多個APP

那麼怎麼只產生一個呢

650) this.width=650;" src="https://s1.51cto.com/oss/201711/11/0e79ba69f3182e6c5acca10adc2d155c.png-wh_500x0-wm_3-wmp_4-s_3976241098.png" title="QQ圖片20171111171821.png" alt="0e79ba69f3182e6c5acca10adc2d155c.png-wh_" />

把launcher改成default即可

android-清單小檔案

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.