请大家帮忙看一下这段代码,一直提示The method getText() is undefined for the type String
packagecom.weinaiji;importcom.weinaiji.R.string;importandroid.app.Activity;importandr...
package com.weinaiji;
import com.weinaiji.R.string;
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.os.Build;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
public class insertData extends Activity {
private CunChuActivity dpHlp;
@Override
public void onResume(){
super.onResume();
if(dpHlp==null)
dpHlp=new CunChuActivity(this, null, null, 0);
}
@Override
public void onPause(){
super.onPause();
Menu dbHlp = null;
if(dbHlp!=null){
dbHlp.close();
dbHlp=null;
}
}
private void findViews(){
EditText nian = (EditText)findViewById(R.id.nian);
EditText yue = (EditText)findViewById(R.id.yue);
EditText ri = (EditText)findViewById(R.id.ri);
EditText shi = (EditText)findViewById(R.id.shi);
EditText fen = (EditText)findViewById(R.id.fen);
EditText haosheng = (EditText)findViewById(R.id.haosheng);
Button buttonqueding = (Button)findViewById(R.id.buttonqueding);
buttonqueding.setOnClickListener(new OnClickListener(){
public void onClick(View v){
String nian=nian.getText().toString().trim();
String yue=yue.getText().toString().trim();
String ri=ri.getText().toString().trim();
String shi=shi.getText().toString().trim();
String fen=fen.getText().toString().trim();
String haosheng=haosheng.getText().toString().trim();
if(nian.length()<=0||yue.length()<=0||ri.length()<=0){
Toast.makeText(insertData.this, getString(R.string.blank), Toast.LENGTH_SHORT).show();
return;
}
StringBuilder sb=new StringBuilder();
ContentValues shuju=new ContentValues();
Object dbHlp;
long rowId=((CunChuActivity) dbHlp).insertDB(shuju);
if(rowId!=-1){
sb.append(getString(R.string.insert_success));
}else{
sb.append(getString(R.string.insert_fail));
}
Toast.makeText(insertData.this, sb, Toast.LENGTH_SHORT).show();
}
});
}
} 展开
import com.weinaiji.R.string;
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.os.Build;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
public class insertData extends Activity {
private CunChuActivity dpHlp;
@Override
public void onResume(){
super.onResume();
if(dpHlp==null)
dpHlp=new CunChuActivity(this, null, null, 0);
}
@Override
public void onPause(){
super.onPause();
Menu dbHlp = null;
if(dbHlp!=null){
dbHlp.close();
dbHlp=null;
}
}
private void findViews(){
EditText nian = (EditText)findViewById(R.id.nian);
EditText yue = (EditText)findViewById(R.id.yue);
EditText ri = (EditText)findViewById(R.id.ri);
EditText shi = (EditText)findViewById(R.id.shi);
EditText fen = (EditText)findViewById(R.id.fen);
EditText haosheng = (EditText)findViewById(R.id.haosheng);
Button buttonqueding = (Button)findViewById(R.id.buttonqueding);
buttonqueding.setOnClickListener(new OnClickListener(){
public void onClick(View v){
String nian=nian.getText().toString().trim();
String yue=yue.getText().toString().trim();
String ri=ri.getText().toString().trim();
String shi=shi.getText().toString().trim();
String fen=fen.getText().toString().trim();
String haosheng=haosheng.getText().toString().trim();
if(nian.length()<=0||yue.length()<=0||ri.length()<=0){
Toast.makeText(insertData.this, getString(R.string.blank), Toast.LENGTH_SHORT).show();
return;
}
StringBuilder sb=new StringBuilder();
ContentValues shuju=new ContentValues();
Object dbHlp;
long rowId=((CunChuActivity) dbHlp).insertDB(shuju);
if(rowId!=-1){
sb.append(getString(R.string.insert_success));
}else{
sb.append(getString(R.string.insert_fail));
}
Toast.makeText(insertData.this, sb, Toast.LENGTH_SHORT).show();
}
});
}
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询