我正在尝试将坐标发送到MapsActivity,我想用吐司测试代码,但它不会创建任何吐司。其他任何事情都很有效......
我的原始代码有意图,我看到他们没有工作,检查,我添加了祝酒词,我看到它仍然无法正常工作。
行只包含两个TextView。没别了。
此外,我尝试使用按钮发送数据,按钮也不起作用......
对不起,我的英语很差,所以我希望我能很好地解释我的问题。
以下代码是我的MainActivity.java的简短版本。
public class MainActivity extends AppCompatActivity implements LocationListener {
private TextView latituteField;
ArrayList<HashMap<String, String>> studentList;
private TextView longitudeField;
private ListView lsv;
private LocationManager locationManager;
private String provider;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lsv = (ListView) findViewById(R.id.listView);
...
}
...
@Override
public void onLocationChanged(Location location) {
// I'm refreshing the page if location changed, so the reason of running this code is this.
lsv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(),"A",Toast.LENGTH_LONG);
}
});
}
...
//Here comes the AsyncTask,
class RequestTask extends AsyncTask<String, String, String> {
// Hashmap for ListView
String viewcor;
private RequestTask(String coord) {
this.viewcor= coord;
}
...
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//TextView AsA = (TextView) findViewById(R.id.textView3);
ListView ssss = (ListView) findViewById(R.id.listView);
//AsA.setText(s+"");
final ListAdapter adapter = new SimpleAdapter(
MainActivity.this, studentList,
R.layout.lust, new String[]{"id","mesafe"}, new int[]{R.id.name, R.id.mesafe});
ssss.setAdapter(adapter);
}
答案 0 :(得分:0)
将.show()
添加到Toast.makeText(getApplicationContext(),"A",Toast.LENGTH_LONG);
像这样:Toast.makeText(getApplicationContext(),"A",Toast.LENGTH_LONG).show();