私は文字列の最終的なリストを持っています (SetonClickListener で使用するには、最終的なリストである必要があります)。このリストに項目を追加しようとすると、「UnSoppurtedOperationException」がスローされます。
これはlogcatです:
04-06 09:05:35.585: E/AndroidRuntime(1179): FATAL EXCEPTION: main
04-06 09:05:35.585: E/AndroidRuntime(1179): java.lang.UnsupportedOperationException
04-06 09:05:35.585: E/AndroidRuntime(1179): at java.util.AbstractList.add(AbstractList.java:404)
04-06 09:05:35.585: E/AndroidRuntime(1179): at java.util.AbstractList.add(AbstractList.java:425)
04-06 09:05:35.585: E/AndroidRuntime(1179): at com.example.sale.GroupActivity$MyCustomAdapter$1.onClick(GroupActivity.java:385)
04-06 09:05:35.585: E/AndroidRuntime(1179): at android.view.View.performClick(View.java:4204)
04-06 09:05:35.585: E/AndroidRuntime(1179): at android.view.View$PerformClick.run(View.java:17355)
04-06 09:05:35.585: E/AndroidRuntime(1179): at android.os.Handler.handleCallback(Handler.java:725)
04-06 09:05:35.585: E/AndroidRuntime(1179): at android.os.Handler.dispatchMessage(Handler.java:92)
04-06 09:05:35.585: E/AndroidRuntime(1179): at android.os.Looper.loop(Looper.java:137)
04-06 09:05:35.585: E/AndroidRuntime(1179): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-06 09:05:35.585: E/AndroidRuntime(1179): at java.lang.reflect.Method.invokeNative(Native Method)
04-06 09:05:35.585: E/AndroidRuntime(1179): at java.lang.reflect.Method.invoke(Method.java:511)
04-06 09:05:35.585: E/AndroidRuntime(1179): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-06 09:05:35.585: E/AndroidRuntime(1179): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-06 09:05:35.585: E/AndroidRuntime(1179): at dalvik.system.NativeStart.main(Native Method)
04-06 09:05:38.784: I/Process(1179): Sending signal. PID: 1179 SIG: 9
04-06 09:05:39.694: E/Trace(1425): error opening trace file: No such file or directory (2)
これは私のコードです:
String name="a";
String freindsAccepted = groupFreindsAcceptedInside.get(position);
final List<String> accepted = Arrays.asList(freindsAccepted.split(","));
final String[] arrayAccepted = accepted.toArray(new String[accepted.size()]);
acceptBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Thread thread = new Thread()
{
@Override
public void run() {
//perform something
}
};
thread.start();
accepted.add(name);
String[] arrayAcceptedInside = accepted.toArray(new String[accepted.size()]);
if(accepted.size()>1) {
groupAccepted.setText("Accepted: "+accepted.get(0)+","+ accepted.get(1)+"...see More");
}
else {
groupAccepted.setText("Accepted: "+accepted.get(0));
}
}
});
385行目は次のとおりです。
accepted.add(name);
どうもありがとう