Android综合下载系统的开发步骤以及遇到问题

1.设置title为”Android综合下载测试系统”。

2.android:gravity="center",将TextView中的字体设置为居中。

3. “Error in an XML file: aborting build.”,出现该问题,使用project->clean消除bug

4.使用res/values/color.xml,这样可以使用android:background=”@drawable/white”

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

<resources>

       <drawablename="darkgray">#808080FF</drawable>

       <drawablename="white">#FFFFFFFF</drawable>

</resources>

5.中途出现了一些小插曲,如果MyEclipse无法打开时,

The quickest wayto fix this or any other resource-related exception is to:

Shut down EclipseIDE

Remove and backupyour workspace/.metadata/.plugins/org.eclipse.core.resources directory

Start Eclipse IDE(with -clean to be super-safe)

Reimport allprojects (UPDATE: Just use File->Import->Existing Project into Workspaceand browse your workspace/project directory)

Enjoy

6.android:inputType="textPassword"将输入框设置为密码格式

7.生成一个checkbox,注意加粗体,否则报错

  <CheckBox

         android:id="@+id/display"

         android:layout_width="wrap_content"

         android:layout_height="wrap_content"

         android:text="@string/display"

         />

8.在main.xml中嵌入一个relativeLayout

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

 

9.使用相对布局将loginButton放在searchButton的左边

  android:layout_toRightOf="@id/buttonSearch"

10.设置密码可以显示不可以显示代码:

if(display.isChecked()){

                                               //将密码显示出来

                                               //myPassword控件进行设置TransformationMethod                    myPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());

                                     }else{

                                               //不显示密码

         myPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());

                                     }

11.进行登陆操作

  密码错误时:使用Toast方法来显示信息

  Toast.makeText(Login.this, "密码错误!" , Toast.LENGTH_LONG).show();

  密码正确时,使用Intent方法进入下一个Activity

12.在新的一个Activity中创建布局描述文件.xml,注意:android:orientation="vertical"

13.添加RadioGroup以及RadioButton

   <RadioGroup

         android:id="@+id/typeGroup"

         android:layout_width="wrap_content"

         android:layout_height="wrap_content"

         android:orientation="vertical"

         >

         <RadioButton

                   android:id="@+id/xml"

                   android:layout_width="wrap_content"

                   android:layout_height="wrap_content"

                   android:text="@string/xml"

                   />

14.为RadioGroup添加OnCheckedListener监听器

//为RadioGroup添加监听器

                   typeGroup.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener() {

                           

                            @Override

                            public voidonCheckedChanged(RadioGroup group, int checkedId) {

                                     // TODOAuto-generated method stub

                                     if(xml.getId()== checkedId){

                                               flag= 1;

                                     }elseif(txt.getId() == checkedId){

                                               flag= 2;

                                     }elseif(mp3.getId() == checkedId){

                                               flag= 3;

                                     }

                                    

                            }

                   });

相关推荐