How can I remove comma, opening and closing square bracket after the new image path appears in the Toast??
Consider the following code:
btnSave = (Button) findViewById(R.id.btnSaveAlbum);
btnSave.setOnClickListener(new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onClick(View v) {
if (requestCode == 200 && resultCode == Activity.RESULT_OK) {
String[] apath = data.getStringArrayExtra("all_path");
ArrayList<String> strings = new ArrayList<String>();
for (String string : apath) {
strings.add(string);
Toast.makeText(MainActivity.this, strings.toString(), Toast.LENGTH_LONG).show();
}
}
}
});
Sample Image
答案 0 :(得分:1)
您可以这样做:
String myString = "[mytext]";
myString = myString.replace("[", "");
myString = myString.replace("]", "");
String[] parts = myString.split(",");
String part1 = parts[0];
String part2 = parts[1];
...