调整心态,重新看待自己和别人

我总是这样一个人,情绪低落到一定程度就得重新调整回来。现在被两大问题所阻挡,苦思无解法。那也实在没办法了,只能一点点去磨了。其实,这都是一个心态的问题,把自己看的太高,或太低都是不恰当的,真正重要的是我们自己心底想什么,想要什么,想要什么该怎么做。作为IT工作者,职业困惑是难免的,有的人来的早,有的人来的晚。晚上关上灯,问问自己这是你想要的工作吗?看看你身边比你年长的同事,过几年是不是你也和他一样,如果你觉得这就是你想要的。恭喜你,你在自己的道路上,坚持走下去。如果不是,你就要好好思考了,这个决定肯那个很困难,但是得做。呵呵,这是一个技术博客,讲那么多感想不太合适。

最近,研究了google的android系统,多少学到了一些新鲜的东西。因为是初学者,所以很痛苦,呵呵,毕竟平台不一样了。总的来说,我个人觉得Android的界面系统跟WPF很类似,或许以XML来定义界面元素是一种趋势吧。Android中也比较提倡使用这种方式来布局界面。所以你可以把通常的界面元素都放到XML中去,

代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation
="vertical"
    android:layout_width
="fill_parent"
    android:layout_height
="fill_parent"
    
>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width
="fill_parent" 
    android:layout_height
="wrap_content" 
    android:text
=""
    android:id 
="@+id/button"
    android:nextFocusLeft
="@+id/checkbox"
    
/>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width
="fill_parent"
    android:layout_height
="wrap_content"
    android:text
=""
    android:id
="@+id/edit"/>
<CheckBox 
    
android:layout_width="fill_parent"
    android:layout_height
="wrap_content"
    android:text
="This is test checkbox"
    android:id 
= "@+id/checkbox"
    android:background
="@color/green"
     
/>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
    android:id 
= "@+id/radiogroup"
    android:layout_width 
= "fill_parent"
    android:layout_height
="wrap_content"
    android:orientation
="vertical">
    
<RadioButton android:layout_width="wrap_content"
                 android:layout_height
="wrap_content"
                 android:id
="@+id/radio1"
                 android:text
="A"/>
    
<RadioButton android:layout_width="wrap_content"
                 android:layout_height
="wrap_content"
                 android:id
="@+id/radio2"
                 android:text
="B"/>
</RadioGroup>
</LinearLayout>

 

Android中有三个非常重要的XML:layout/main.xml,values/strings.xml,AndroidManifest.xml。这几个文件的含义我也不在这里赘述了,www.android.com/developer里面都有介绍。不过值得强调的是,事实上你可以自己定义更多界面元素的 xml文件将它们放到layout文件夹中,然后同R.layout.xxx去访问。另外一点是,凡是用xml的都可以用代码来实现,所以不需要过于刻意的使用xml。反正我不是很喜欢,呵呵。

代码
package code.moonzwu;

import android.R.integer;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.widget.CompoundButton.OnCheckedChangeListener;
import java.util.Date;

public class beginAndroidOne extends Activity implements View.OnClickListener, OnCheckedChangeListener {
    Button btn 
= null;
    EditText edtxt 
= null;
    CheckBox chbox 
= null;
    
/** Called when the activity is first created. */
    @Override
    
public void onCreate(Bundle savedInstanceState) {
        
super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
//btn = new Button(this);
        btn = (Button)findViewById(R.id.button);
        btn.setOnClickListener(
this);
        updateDate();
        
        edtxt 
= (EditText)findViewById(R.id.edit);
        edtxt.setOnClickListener(
this);
        edtxt.setText(
"This is test text");
        
        chbox 
= (CheckBox)findViewById(R.id.checkbox);
        chbox.toggle();
        chbox.setOnCheckedChangeListener(
this);

    }
    
    @Override
    
public void onClick(View v) {
        updateDate();
    }
    
    
private void updateDate() {
        btn.setText(
new Date().toString());
    }

    @Override
    
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
        
// TODO Auto-generated method stub
        RadioGroup rGroup = (RadioGroup)findViewById(R.id.radiogroup);
        
int id = rGroup.getCheckedRadioButtonId();
        chbox.setText(((RadioButton)findViewById(id)).getText());
    }

    
}

 

因为是学习的代码,所以很乱,大家就将就一些吧。^_^

posted @ 2010-03-16 23:20  moonz-wu  阅读(398)  评论(0编辑  收藏  举报