1 代码参考自郭霖大神博客http://blog.csdn.net/guolin_blog/article/details/38556989
2 大神创造的框架一个字用起来就是爽
3 主界面MainActivity代码:
package com.example.androidlitepal;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.litepal.crud.DataSupport;
import org.litepal.tablemanager.Connector;
import com.example.androidClass.Category;
import com.example.androidClass.Comment;
import com.example.androidClass.Introduction;
import com.example.androidClass.News;
import android.app.Activity;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
public class MainActivity extends Activity implements OnClickListener {
Button btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btn10, btn11, btn12, btn13, btn14, btn15, btn16, btn17,
btn18, btn19, btn20, btn21, btn22, btn23, btn24, btn25, btn26, btn27, btn28, btn29, btn30, btn31, btn32;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1 = (Button) findViewById(R.id.button1);
btn2 = (Button) findViewById(R.id.button2);
btn3 = (Button) findViewById(R.id.button3);
btn4 = (Button) findViewById(R.id.button4);
btn5 = (Button) findViewById(R.id.button5);
btn6 = (Button) findViewById(R.id.button6);
btn7 = (Button) findViewById(R.id.button7);
btn8 = (Button) findViewById(R.id.button8);
btn9 = (Button) findViewById(R.id.button9);
btn10 = (Button) findViewById(R.id.button10);
btn11 = (Button) findViewById(R.id.button11);
btn12 = (Button) findViewById(R.id.button12);
btn13 = (Button) findViewById(R.id.button13);
btn14 = (Button) findViewById(R.id.button14);
btn15 = (Button) findViewById(R.id.button15);
btn16 = (Button) findViewById(R.id.button16);
btn17 = (Button) findViewById(R.id.button17);
btn18 = (Button) findViewById(R.id.button18);
btn19 = (Button) findViewById(R.id.button19);
btn20 = (Button) findViewById(R.id.button20);
btn21 = (Button) findViewById(R.id.button21);
btn22 = (Button) findViewById(R.id.button22);
btn23 = (Button) findViewById(R.id.button23);
btn24 = (Button) findViewById(R.id.button24);
btn25 = (Button) findViewById(R.id.button25);
btn26 = (Button) findViewById(R.id.button26);
btn27 = (Button) findViewById(R.id.button27);
btn28 = (Button) findViewById(R.id.button28);
btn29 = (Button) findViewById(R.id.button29);
btn30 = (Button) findViewById(R.id.button30);
btn31 = (Button) findViewById(R.id.button31);
btn32 = (Button) findViewById(R.id.button32);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
btn4.setOnClickListener(this);
btn5.setOnClickListener(this);
btn6.setOnClickListener(this);
btn7.setOnClickListener(this);
btn8.setOnClickListener(this);
btn9.setOnClickListener(this);
btn10.setOnClickListener(this);