从一个EditText中检索多个变量

时间:2015-06-05 03:07:25

标签: java android android-fragments android-edittext

我一直致力于创建翻译应用。我从数据库中检索一个数据没有遇到任何问题。我想从EditText的一个条目中获取多个字符串并在一个TextView中显示它。这是我的代码:

db = new DatabaseHelper(super.getActivity()).getWritableDatabase();

searchText = (EditText) rootView.findViewById(R.id.searchText);
melanauTextView = (TextView) rootView.findViewById(R.id.myTextView);

Button btn = (Button) rootView.findViewById(R.id.searchButton);
btn.setOnClickListener(new View.OnClickListener() {
    public void onClick(View V) {
        cursor = db.rawQuery("SELECT * FROM translate WHERE malayText = ?", 
                             new String[]{searchText.getText().toString()});

        if ((cursor != null) && (cursor.moveToFirst()))
                    melanauTextView.setText(String.format("%s", 
                    cursor.getString(cursor.getColumnIndex("melanauText"))));

    }
}

非常感谢任何建议或要点。

0 个答案:

没有答案
相关问题