| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1754 人关注过本帖
标题:明天考试题,大神求帮助
取消只看楼主 加入收藏
LICHENG712
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-12-30
收藏
 问题点数:0 回复次数:0 
明天考试题,大神求帮助
package com.example.jrkl;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.jrkl.R;

public class ChangeActivity extends Activity{
    EditText edPwd,edId,edAge,edName;
    Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_change);

        edPwd = (EditText) findViewById(R.id.ed_change_pwd);
        edId = (EditText) findViewById(R.id.ed_change_userid);
        edAge = (EditText) findViewById(R.id.ed_change_age);
        edName = (EditText) findViewById(R.id.ed_change_name);

        btn = (Button) findViewById(R.id.btnChange);

        String sql = "SELECT * FROM user WHERE "+Constant.USERID+"=?";
        Cursor cursor = new Tools(getBaseContext()).getDataBase().rawQuery(sql, new String[]{new Tools(getBaseContext()).getPreferenceHelper().getString((Constant.USERID))});
        while(cursor.moveToNext()){
            String pwd = cursor.getString(cursor.getColumnIndex(Constant.PWD));
            String age = cursor.getString(cursor.getColumnIndex(Constant.AGE));
            String name = cursor.getString(cursor.getColumnIndex(Constant.NAME));
            String userid = cursor.getString(cursor.getColumnIndex(Constant.USERID));
            
            edPwd.setText(pwd);
            edId.setText(userid);
            edAge.setText(age);
            edName.setText(name);
        }
        btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                String id = edId.getText().toString();
                String pwd = edPwd.getText().toString();
                String age = edAge.getText().toString();
                String name = edName.getText().toString();


                if(id.equals("") || pwd.equals("") ||age.equals("") ||name.equals("")){
                    Toast.makeText(getApplicationContext(), "请输入完整信息", Toast.LENGTH_SHORT).show();
                    return;
                }


                ContentValues values = new ContentValues();
                values.put(Constant.USERID, id);
                values.put(Constant.NAME, name);
                values.put(Constant.PWD, pwd);
                values.put(Constant.AGE, age);
                new Tools(getBaseContext()).getDataBase().update("user", values, Constant.USERID+"=?",
                        new String[]{new Tools(getBaseContext()).getPreferenceHelper().getString((Constant.USERID))});
               
                new Tools(getBaseContext()).getPreferenceHelper().putString(Constant.USERID, id);
                Toast.makeText(getApplicationContext(), "更新成功", Toast.LENGTH_SHORT).show();

               
                finish();
            }
        });
    }

}
明天考试,老师给了这么一段程序,完全不懂。。。求大神告诉~写的什么意思
搜索更多相关主题的帖子: package import public 考试题 
2015-12-30 21:17
快速回复:明天考试题,大神求帮助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037921 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved