java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)

时间:2014-10-05 18:20:26

标签: android

它给了我非常奇怪的输出。在我第一次输入时,地图摄像头显示了toast msg"地址未找到"在我的第二次输入它带我到我的第一个位置...并继续这个过程我给了上述例外...任何提示,帮助,链接将非常感谢... thankx..`

public void geolocation(View v) throws IOException   {
         if (check_connection()==false)
         {
             alert_user();
         }
         hidesoftkeyboard(v);
         EditText et = (EditText) findViewById(R.id.edit_text1);
         location= et.getText().toString();
          gc = new Geocoder(this);
          new my_second_thread().execute();
         if (list == null )
         {
             Toast.makeText(this,"address not found",Toast.LENGTH_SHORT).show();
             return;

         }
         else if ( list.size() > 0)
         {
             Address add = list.get(0);
             String locality = add.getLocality();
             Toast.makeText(this,"moving..", Toast.LENGTH_SHORT).show();

            double latitude = add.getLatitude();
            double longitude = add.getLongitude();
            gotoloc(latitude, longitude, zoom);
            add_markers(latitude, longitude, locality);

         }

    }

//the above function uses asyntask which is:

    class my_second_thread extends AsyncTask<String, String, List<Address>>{
        @Override
        protected List<Address> doInBackground(String... params) {
           try {
            return gc.getFromLocationName(location, 1);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
        }


        @Override
        protected void onPostExecute(List<Address> result) {
            list = result;
        }

}``

0 个答案:

没有答案