2013.9.17 fastjson,BaseActivity
3451 ワード
1,fastjson
jsonはファイル交換のプロトコルで、中にはツールjackjson、fastjsonなどに貢献した人がいて、私は一線のプログラマーとしてツールで効率的に仕事を完成しました.
類似:httpプロトコル、httpclientツール、私の使用者.
シーケンス化:
逆シーケンス化:
2,BaseActivity
1)多くのインタフェースには,同じtitlebarやfooterbarなど,同じインタフェースを独立させたBaseActivityのような類似のレイアウトがある.界面性のBaseActivity
ui_base.xml
2)もう1つは機能的なBaseActivityで、多くの場合混在している可能性があります
jsonはファイル交換のプロトコルで、中にはツールjackjson、fastjsonなどに貢献した人がいて、私は一線のプログラマーとしてツールで効率的に仕事を完成しました.
類似:httpプロトコル、httpclientツール、私の使用者.
シーケンス化:
Object o = ...;
String text = JSON.toJSONString(o);
逆シーケンス化:
String text = ...;
// {"name":" ", "age":66}
JSONObject json = JSON.parseObject(text);
Object o = ....;
JSONObject json = (JSONObject) JSON.toJSON(o);
2,BaseActivity
1)多くのインタフェースには,同じtitlebarやfooterbarなど,同じインタフェースを独立させたBaseActivityのような類似のレイアウトがある.界面性のBaseActivity
public class UiBaseActivity extends Activity implements OnClickListener {
private Button pre_page;
private Button next_page;
private TextView title;
private LinearLayout content;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ui_base);
findViewById();
pre_page.setOnClickListener(this);
next_page.setOnClickListener(this);
}
private void findViewById() {
pre_page = (Button) findViewById(R.id.pre_page);
next_page = (Button) findViewById(R.id.next_page);
title = (TextView) findViewById(R.id.title);
content = (LinearLayout) findViewById(R.id.content);
}
@Override
public void onClick(View v) {
if(v.getId() == R.id.pre_page){
Toast.makeText(this, "pre_page", 0).show();
}else if(v.getId() == R.id.next_page){
Toast.makeText(this, "next_page", 0).show();
}
}
public void setTitleBarTitle(String title){
if(this.title != null){
this.title.setText(title);
}
}
public void setEmbededContentView(int childViewId){
LinearLayout llContent = (LinearLayout) findViewById(R.id.content);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(childViewId, null);
llContent.addView(v);
}
}
ui_base.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/pre_page"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text=" "/>
<Button
android:id="@+id/next_page"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text=" "/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="default" />
<LinearLayout
android:id="@+id/content"
android:layout_below="@+id/pre_page"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></LinearLayout>
</RelativeLayout>
2)もう1つは機能的なBaseActivityで、多くの場合混在している可能性があります