我正在做学校作业,需要一些帮助。
Android 我将这些坐标存储在 sdcard 的 txt 文件中,它们以这种方式存储
x.xxxxxxxx|x.xxxxxxxxxy
x.xxxxxxxx|x.xxxxxxxxxx
等等。我正在做的是尝试使用 listview.onclicklistener(){,所以一旦我点击一个文件,它就会读取它并向带有数据的地图发送一个意图。我想要的是将它存储在两个不同的数组中,例如同一文件中的经度 [] 和纬度 [],以发送到 map.class 以用作创建标记的参数。我知道如何拆分它,但我不知道如何将它们存储到单独的数组中。
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            File logFile = new File(Environment.getExternalStorageDirectory().toString(), "GPSLogger/testfile.txt");
            InputStream instream = null;
            try {
                instream = new FileInputStream(logFile);
            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
            String line = null;
            String[] Location = null;
            int i = 0;
            String[] Longitude = null;
            String[] Latitude = null;
            try {
                while((line = reader.readLine()) != null){
                    Log.v("result" ,result);
                    result += line + "|";
                    Location = result.split("\\|");
                    for (String s : Location) {
                        Log.v("asd",s);
                        i++;
                        if(i%2==0){
                            String[] Longitude = Location[0];
                        }
                        else{
                            String Latitude = Location[0];
                        }
                    }
这就是我正在尝试的,但我遇到了很多错误。请提前帮助和感谢!