I am trying to pass data through an intent, but its throwing an error I don't understand.
Activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_editor);
conn = new ConnectionDetector(this);
mEditorAdapater = new EditorAdapter(this, new ArrayList<ParseObject>());
mListView = (ListView) findViewById(R.id.listEditor);
mListView.setAdapter(mEditorAdapater);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout_edit);
swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
swipeRefreshLayout
.setRefreshing(true);
queryPieces();
}
});
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String title = pieces.get(position).getString("title");
String status = pieces.get(position).getString("status");
String story = pieces.get(position).getString("story");
String category = pieces.get(position).getString("category");
String location = pieces.get(position).getString("location");
String journo = pieces.get(position).getString("Journo");
String objectId = pieces.get(position).getObjectId();
// byte[] storyClip = pieces.get(position).getBytes("storyClip");
Intent in = new Intent(Editor.this, EditPieceActivity.class);
in.putExtra("title", title);
in.putExtra("status", status);
in.putExtra("story", story);
in.putExtra("category", category);
in.putExtra("location", location);
in.putExtra("id", objectId);
startActivity(in);
//in.putExtra()
}
});
pieces = new ArrayList<ParseObject>();
}
and this is the error am getting android is not being helpful in telling me what is wrong.
Error:
10-06 10:16:52.675 12167-12167/main.itprogrammer.journo E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: main.itprogrammer.journo, PID: 12167
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at main.itprogrammer.journo.Editor$2.onItemClick(Editor.java:56)
at android.widget.AdapterView.performItemClick(AdapterView.java:299)
at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:2911)
at android.widget.AbsListView$3.run(AbsListView.java:3645)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)