Android

编写Android遇到的问题和解决方法
一、Android程序的简单代码的步骤
  1、创建一个Android project
  2、在res文件夹下的layout和values下创建分别建立main.xml和strings.xml
  3、在创建的AVD下运行所创建的项目
二、Android小程序分享
1、 创建了一个lanyao的Android项目
2、生成的.java文件
   package com.cn;

import android.app.Activity;
import android.os.Bundle;

public class LanyaoActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
3、main.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="wrap_content"
    android:background="@color/redground"
    android:orientation="vertical" >







    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/redground"
        android:text="                 欢迎进入Android的世界" />




    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/redground"
        android:text="按钮" />

    <MultiAutoCompleteTextView
        android:background="@color/redground"
        android:id="@+id/multiAutoCompleteTextView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:text="队名:似水年华" >

        <requestFocus />
    </MultiAutoCompleteTextView>


    <MultiAutoCompleteTextView
        android:id="@+id/multiAutoCompleteTextView4"
        android:layout_width="363dp"
        android:layout_height="wrap_content"
        android:background="@color/redground"
        android:ems="10"
        android:text="           队长:郝一肖" />

    <MultiAutoCompleteTextView
        android:background="@color/redground"
        android:id="@+id/multiAutoCompleteTextView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:text="           我们团队的那些事" />

    <MultiAutoCompleteTextView
        android:background="@color/redground"
        android:id="@+id/multiAutoCompleteTextView3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:text="           团队的照片" />

    <TableRow
        android:background="@color/redground"
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

    </TableRow>


    <AnalogClock
        android:id="@+id/analogClock1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/redground" />

    <MultiAutoCompleteTextView
        android:id="@+id/multiAutoCompleteTextView5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/redground"
        android:ems="10"
        android:text="              Android的世界精彩无限!!" />


    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/redground"
        android:src="@drawable/ic_launcher" />
      </LinearLayout>
   4、color.xml的代码
    <?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="redground">#3500ffff</color>
</resources>
   5、string.xml的代码
   <?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="hello">Hello World, LanyaoActivity!</string>
    <string name="app_name">Lanyao</string>

</resources>
   5、运行的结果
   
Android
   三、写程序遇到的问题
color.xml 不能运行成功
   四、解决方法
   1、问老师
   2、自己修改运行,查看出错的原因
   3、查百度
  

   

你可能感兴趣的:(android,学习)