-1
この画像をedittext(太字のイタリックと標準のオプション)のようなテキストスタイルにするユーザーオプションを与えたい。最初のユーザーは、EditTextで書かれたテキストのtextStyleを変更するボタンをクリックする。 : EditText編集ボックス
これは私が欲しい私のEditText compdesceでコード
public class Addnew extends Activity {
Spinner spinner;
String select=null;
private String selec(String selected){
return selected;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.addnew);
spinner = (Spinner) findViewById(R.id.comptypeinput);
ArrayAdapter<CharSequence> spin= ArrayAdapter.createFromResource(Addnew.this,R.array.spinner,android.R.layout.simple_spinner_item);
spin.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
spinner.setAdapter(spin);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
String selected = null;
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
selected = arg0.getItemAtPosition(arg2).toString();
select = selec(selected);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
Toast.makeText(Addnew.this, "Please Select Complaint Type", Toast.LENGTH_LONG).show();
}
});
Button submit = (Button) findViewById(R.id.insert);
submit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
EditText comptimee= (EditText) findViewById(R.id.timeinput);
EditText compaddresse= (EditText) findViewById(R.id.addressinput);
EditText compdesce = (EditText) findViewById(R.id.descriptioninput);
String username= getIntent().getStringExtra("user");
String comptime = comptimee.getText().toString();
String compaddress = compaddresse.getText().toString();
String compdesc = compdesce.getText().toString();
AddnewAsync as=new AddnewAsync();
as.execute(select,comptime,compdesc,compaddress,username);
}
});
}
private class AddnewAsync extends AsyncTask<String, Void, String>{
private Dialog pd ;
@Override
protected String doInBackground(String... params) {
List<NameValuePair> nvp = new ArrayList<NameValuePair>();
nvp.add(new BasicNameValuePair("comp_type", params[0]));
nvp.add(new BasicNameValuePair("availtime", params[1]));
nvp.add(new BasicNameValuePair("description", params[2]));
nvp.add(new BasicNameValuePair("address", params[3]));
nvp.add(new BasicNameValuePair("username", params[4]));
HttpClient hc = new DefaultHttpClient();
HttpPost hp = new HttpPost("http://172.31.144.231/test/andcompinsert.php");
StringBuilder sb = new StringBuilder();
String result=null;
try {
hp.setEntity(new UrlEncodedFormEntity(nvp));
HttpResponse response = hc.execute(hp);
HttpEntity ent= response.getEntity();
InputStream is = ent.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = null;
while((line=reader.readLine())!= null){
sb.append(line+"\n");
}
result = sb.toString();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
@Override
protected void onPreExecute() {
pd = ProgressDialog.show(Addnew.this, "Please Wait", "Uploading");
super.onPreExecute();
}
@Override
protected void onPostExecute(String result) {
pd.dismiss();
String s = result.trim();
if(s.equals("success")){
Toast.makeText(Addnew.this, "Updated Successfully", Toast.LENGTH_LONG).show();
Intent inten = new Intent(Addnew.this,PreviousComp.class);
String username= getIntent().getStringExtra("user");
inten.putExtra("user", username);
startActivity(inten);
}else{
Toast.makeText(Addnew.this, "Error Updating... Please Try Again...", Toast.LENGTH_LONG).show();
}
super.onPostExecute(result);
}
}
}
オプションことです。スタイリングテキストテキストの<b> </b>
およびなどのような
データベースに書き込もうとしているコードを確認できますか? –
i asyctaskを使用してhttpリクエストを送信し、データベースに保存しています。特別なことは何もありません。単純なエディットテキストと実行ボタンasyctask @blahfunk – Mayank
あなたが私たちに示したことは、あなたがしたいことだけです。あなたは私たちにあなたを助けるためのコードを提示していません。私たちはあなたのコードを書きませんが、あなたが書いたコードを修正するのに役立ちます。エラーが発生している場所であるため、データベースに書き込むために使用しているコードを参照してください。 –