/**

 * 源码片段

 */

package wordroid.activitys;

 

import java.util.ArrayList;

 

import wordroid.database.DataAccess;

import wordroid.model.R;

import wordroid.model.Word;

import android.app.Activity;

import android.app.AlertDialog;

import android.app.Dialog;

import android.content.DialogInterface;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

import android.widget.Toast;

 

/**

 * @author Administrator

 *

 */

public class EditWord extends Activity implements OnClickListener{

    private String action;

    private EditText spelling;

    private EditText meanning;

    private Button confirm;

    private Button cancel;

    private Word word;

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        this.setTitle("编辑生词本");

        this.setContentView(R.layout.editword);

        Bundle bundle = this.getIntent().getExtras();

        action = bundle.getString("action");

        initWidgets();

    }

 

    private void initWidgets() {

        // TODO Auto-generated method stub

        this.spelling = (EditText) this.findViewById(R.id.EditWord_spelling);

        this.cancel = (Button) this.findViewById(R.id.attention_cancel_button);

        this.confirm = (Button) this.findViewById(R.id.attention_confirm_button);

        this.meanning = (EditText) this.findViewById(R.id.EditWord_meanning);

        cancel.setOnClickListener(this);

        confirm.setOnClickListener(this);

        if (action.equals("edit")){

            Bundle bundle = this.getIntent().getExtras();

            DataAccess data = new DataAccess(this);

            Word word =data.QueryAttention("ID ='"+bundle.getString("id")+"'", null).get(0);

            spelling.setText(word.getSpelling());

            meanning.setText(word.getMeanning());

        }

    }

 

    @SuppressWarnings("unused")

    @Override

    public void onClick(View v) {

        // TODO Auto-generated method stub

        if (v==cancel){

            finish();

        }

        if (v==confirm){

            if (meanning.getText().toString().equals("")||spelling.getText().toString().equals("")){

                Toast.makeText(EditWord.this, "信息不能为空", Toast.LENGTH_SHORT).show();

                return;

            }

            if (action.equals("add")){

                boolean add =true;

                final DataAccess data = new DataAccess(this);

                ArrayList words = data.QueryAttention(null, null);

                 

            for(int i=0;i

               


更多相关文章

  1. Android能发音的生词本
  2. 开发可统计单词个数的Android驱动程序(1)
  3. 如何用c语言实现单词统计
  4. c语言统计单词个数的方法
  5. 动画:散列表 | 文本编辑器是如何检查英文单词出错的?

随机推荐

  1. AS gradle
  2. Android部分手机拍照上传返回为空处理
  3. Android App 多语言切换
  4. 基于ARouter的组件化开发
  5. (4.2.14)【android开源工具】常用网址
  6. Android 在一个应用中如何启动另外一个已
  7. Windows下 ndk 编译程序
  8. Android volley框架加载网络图片
  9. 区分Android 和IOS
  10. [android]如何使LinearLayout布局从右向