在android app
我spinner
populate marathi values
来自.xml file
现在我有一个insert.php
insert values from spinner to mysql table
。
但我得到运行时异常:(
Null.exception
strings.xml
<string-array name="problems">
<item>सार्वजनिक पाळणा घर</item>
<item>बस सेवा</item>
<item>सार्वजनिक अभ्यासिका</item>
<item>जॉगीग पार्क</item>
</string-array>
input_box.xml
<Spinner
android:id="@+id/spinner_problems"
android:entries="@array/problems"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
MainActivity.java
final Spinner problems = (Spinner) findViewById((R.id.spinner_problems));
String myvalue = String.valueOf(problems
.getSelectedItem());
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("name",myval));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://wwwd.emo.com/insert.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
BufferedReader reader = new BufferedReader
(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
is.close();
result = sb.toString();
JSONObject json_data = new JSONObject(result);
code=(json_data.getInt("code"));
if(code==1)
{
new DialogTask().execute("Success");
}
else
{
new DialogTask().execute("Failure");
}
答案 0 :(得分:1)
看起来你没有实现微调器点击监听器并且错误地检索值。