1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      10天學(xué)通Android開發(fā)(6)-資源訪問

             

      網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序定制開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了特克斯免費(fèi)建站歡迎大家使用!

      1. 字符串資源

        自動(dòng)生成目錄 :Values,生成了三個(gè)

        App_name: AndroidManifest.xml使用了

        hello_world:activity_main.xml

        代碼讀取:

       Stringstr=getResources().getString(R.string.app_name);

           //   System.out.println(str);

      tv=(TextView)findViewById(R.id.tv)

              tv.setText(R.string.app_name);

       

      2、顏色資源

      android:background="#FF0000",可簡化"#F00"

      不透明:"#FF00",半透明:"#8F00"

      可添加資源:Android xml File類型:value

         "red">#f00

         "green">#0f0

       

       

      調(diào)用自己定義:

         android:background="@Color/red"

      調(diào)用操作系統(tǒng):

      android:background="@Android:Color/black"

       

      3、數(shù)組資源

      創(chuàng)建Value類型的xml文件:

         "arr">

             hello

         baba

         

      調(diào)用:

             String[] arr=getResources().getStringArray(R.array.arr);

             for(String string : arr)

              System.out.println(string);

       

      "@array/arr" />

       

      4 Drawable資源

      AndroidManifest.xml中:android:icon="@drawable/ic_launcher"

      不分分辯率,創(chuàng)建drawable目錄:

      拷進(jìn)png文件:20150103122610.png

      圖片按鈕,如:

        

             android:id="@+id/p_w_picpathView1"

             android:layout_width="wrap_content"

             android:layout_height="wrap_content"

              android:src="@drawable/20150103122610" />

       

      其它按鈕背景:

      android:background="@drawable/20150103122610"

       

      5  菜單資源

      在menu下默認(rèn)生成了菜單項(xiàng):

       

      "http://schemas.android.com/apk/res/android"

          xmlns:app="http://schemas.android.com/apk/res-auto"

          xmlns:tools="http://schemas.android.com/tools"

          tools:context="com.example.resource6.MainActivity">

       

         

             android:id="@+id/action_settings"

             android:orderInCategory="100"

             android:title="@string/action_settings"

             app:showAsAction="never"/>

       

       

      可重寫菜單項(xiàng),菜單的點(diǎn)擊事件如下:

       @verride

         publicboolean onOptionsItemSelected(MenuItemitem)

          {

            switch(item.getItemId()){

            case R.id.action_settings:

                 new AlertDialog.Builder(this).setTitile("標(biāo)題").setMessage("對話框").setPositiveButton("關(guān)閉",null).show();

               

               break;

            case R.id.action_bar

                 Toast.makeText(this,"消息", Toast_LENTH_SHORT).show();

               break;

              

               default:

                  break;     

             }

          }


      文章標(biāo)題:10天學(xué)通Android開發(fā)(6)-資源訪問
      網(wǎng)站鏈接:http://www.ef60e0e.cn/article/pgggic.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        峨边| 南江县| 辉县市| 通州市| 茂名市| 龙井市| 白城市| 时尚| 炎陵县| 新蔡县| 江达县| 隆化县| 岳阳县| 龙胜| 上杭县| 闽侯县| 东源县| 比如县| 镇原县| 石嘴山市| 锦州市| 临泉县| 宣城市| 内丘县| 阿拉尔市| 钟祥市| 台北市| 得荣县| 泉州市| 玛纳斯县| 额济纳旗| 金川县| 龙井市| 合江县| 博客| 卢氏县| 万盛区| 礼泉县| 丘北县| 松潘县| 灌南县|