Note that there are some explanatory texts on larger screens.

plurals
  1. POUnhandled exception type ParseException - Parse.com Example Implementation
    text
    copied!<p>I'm attempting to expand my current source code to include additional rows of data (it works fine using just the textview: empty) however when I attempt to add empty2 to allow for more data to be displayed - I'm running into the error: </p> <p>"Empty2 Cannot Be Resolved Or Is Not A Field"</p> <p>Even though I've created a textview called empty2 </p> <p>Any idea why this might be happening?</p> <p>todo_row.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5sp" android:textSize="25sp" &gt; &lt;TextView android:id="@+id/android:empty2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /&gt; &lt;TextView android:id="@+id/android:empty3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /&gt; &lt;TextView android:id="@+id/android:empty4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /&gt; &lt;TextView android:id="@+id/android:empty5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /&gt; &lt;/TextView&gt; package com.parse.demo; import java.util.List; import android.app.Dialog; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import com.parse.ParseException; import com.parse.ParseObject; import com.parse.ParseQuery; public class ToDoListActivity extends ListActivity { private static final int ACTIVITY_CREATE = 0; private static final int ACTIVITY_EDIT = 1; public static final int INSERT_ID = Menu.FIRST; private static final int DELETE_ID = Menu.FIRST + 1; private List&lt;ParseObject&gt; todos; private Dialog progressDialog; private class RemoteDataTask extends AsyncTask&lt;Void, Void, Void&gt; { // Override this method to do custom remote calls protected Void doInBackground(Void... params) { // Gets the current list of todos in sorted order ParseQuery query = new ParseQuery("TestObject"); query.orderByDescending("_created_at"); try { todos = query.find(); } catch (ParseException e) { } return null; } @Override protected void onPreExecute() { ToDoListActivity.this.progressDialog = ProgressDialog.show(ToDoListActivity.this, "", "Loading...", true); super.onPreExecute(); } @Override protected void onProgressUpdate(Void... values) { super.onProgressUpdate(values); } @Override protected void onPostExecute(Void result) { // Put the list of todos into the list view ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(ToDoListActivity.this, R.layout.todo_row); for (ParseObject todo : todos) { adapter.add((String) todo.get("DataI")); adapter.add((String) todo.get("DataO")); } setListAdapter(adapter); ToDoListActivity.this.progressDialog.dismiss(); TextView empty = (TextView) findViewById(android.R.id.empty); TextView empty2 = (TextView) findViewById(android.R.id.empty2); empty.setVisibility(View.VISIBLE); empty2.setVisibility(View.VISIBLE); } } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView empty = (TextView) findViewById(android.R.id.empty); empty.setVisibility(View.INVISIBLE); TextView empty2 = (TextView) findViewById(android.R.id.empty2); empty2.setVisibility(View.INVISIBLE); new RemoteDataTask().execute(); registerForContextMenu(getListView()); } private void createTodo() { Intent i = new Intent(this, CreateTodo.class); startActivityForResult(i, ACTIVITY_CREATE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (intent == null) { return; } final Bundle extras = intent.getExtras(); switch (requestCode) { case ACTIVITY_CREATE: new RemoteDataTask() { protected Void doInBackground(Void... params) { String DataI = extras.getString("DataI"); String DataO = extras.getString("DataO"); ParseObject todo = new ParseObject("Todo"); todo.put("DataI", DataI); todo.put("DataO", DataO); try { todo.save(); } catch (ParseException e) { } super.doInBackground(); return null; } }.execute(); break; case ACTIVITY_EDIT: // Edit the remote object final ParseObject todo; todo = todos.get(extras.getInt("position")); todo.put("DataI", extras.getString("DataI")); todo.put("DataO", extras.getString("DataO")); new RemoteDataTask() { protected Void doInBackground(Void... params) { try { todo.save(); } catch (ParseException e) { } super.doInBackground(); return null; } }.execute(); break; } } @Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); menu.add(0, INSERT_ID, 0, R.string.menu_insert); return result; } @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add(0, DELETE_ID, 0, R.string.menu_delete); } @Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case DELETE_ID: AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); // Delete the remote object final ParseObject todo = todos.get(info.position); new RemoteDataTask() { protected Void doInBackground(Void... params) { try { todo.delete(); } catch (ParseException e) { } super.doInBackground(); return null; } }.execute(); return true; } return super.onContextItemSelected(item); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case INSERT_ID: createTodo(); return true; } return super.onOptionsItemSelected(item); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Intent i = new Intent(this, CreateTodo.class); i.putExtra("DataI", todos.get(position).getString("DataI").toString()); i.putExtra("DataO", todos.get(position).getString("DataO").toString()); i.putExtra("position", position); startActivityForResult(i, ACTIVITY_EDIT); } } </code></pre> <p>Main.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;ListView android:id="@+id/android:list" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;TextView android:id="@+id/android:empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /&gt; &lt;TextView android:id="@+id/android:empty2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /&gt; &lt;TextView android:id="@+id/android:empty3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /&gt; &lt;TextView android:id="@+id/android:empty4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /&gt; &lt;TextView android:id="@+id/android:empty5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empty" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>SOURCE AFTER ANSWER EDITS:</p> <pre><code>import java.util.List; import com.parse.ParseException; import com.parse.ParseObject; import com.parse.ParseQuery; import android.app.Dialog; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; public class ToDoListActivity extends ListActivity { TextView empty; TextView empty2; private static final int ACTIVITY_CREATE = 0; private static final int ACTIVITY_EDIT = 1; public static final int INSERT_ID = Menu.FIRST; private static final int DELETE_ID = Menu.FIRST + 1; private List&lt;ParseObject&gt; todos; private Dialog progressDialog; private class RemoteDataTask extends AsyncTask&lt;Void, Void, Void&gt; { // Override this method to do custom remote calls public void setVisibility() { empty.setVisibility(View.VISIBLE); empty2.setVisibility(View.VISIBLE); } protected void doInBackground(Void... params) { // Gets the current list of todos in sorted order ParseQuery query = new ParseQuery("TestObject"); query.orderByDescending("_created_at"); try { todos = query.find(); } catch (ParseException e) { return; } runOnUiThread(new Runnable() { public void run() { // }}); } @Override protected void onPreExecute() { ToDoListActivity.this.progressDialog = ProgressDialog.show(ToDoListActivity.this, "", "Loading...", true); super.onPreExecute(); } @Override protected void onProgressUpdate(Void... values) { super.onProgressUpdate(values); } @Override protected void onPostExecute(Void result) { // Put the list of todos into the list view ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(ToDoListActivity.this, R.layout.todo_row); for (ParseObject todo : todos) { adapter.add((String) todo.get("DataI")); adapter.add((String) todo.get("DataO")); adapter.add((String) todo.get("DataRSSI")); adapter.add((String) todo.get("DataSSID")); adapter.add((String) todo.get("DataTIME")); adapter.add((String) todo.get("DataRESTRICTED")); } setListAdapter(adapter); ToDoListActivity.this.progressDialog.dismiss(); // TextView empty = (TextView) findViewById(android.R.id.empty); // empty.setVisibility(View.VISIBLE); } } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_new); empty = (TextView) findViewById(android.R.id.empty); empty.setVisibility(View.INVISIBLE); // empty2 = (TextView) findViewById(android.R.id.empty2); // empty2.setVisibility(View.INVISIBLE); new RemoteDataTask().execute(); registerForContextMenu(getListView()); } private void createTodo() { Intent i = new Intent(this, CreateTodo.class); startActivityForResult(i, ACTIVITY_CREATE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (intent == null) { return; } final Bundle extras = intent.getExtras(); switch (requestCode) { case ACTIVITY_CREATE: new RemoteDataTask() { protected void doInBackground(Void... params) { String DataI = extras.getString("DataI"); String DataO = extras.getString("DataO"); String DataRSSI = extras.getString("DataRSSI"); String DataSSID = extras.getString("DataSSID"); String DataTIME = extras.getString("DataTIME"); String DataRESTRICTED = extras.getString("DataRESTRICTED"); ParseObject todo = new ParseObject("Todo"); todo.put("DataI", DataI); todo.put("DataO", DataO); todo.put("DataRSSI", DataRSSI); todo.put("DataSSID", DataSSID); todo.put("DataTIME", DataTIME); todo.put("DataRESTRICTED", DataRESTRICTED); try { todo.save(); } catch (ParseException e) { } super.doInBackground(); return; } }.execute(); break; case ACTIVITY_EDIT: // Edit the remote object final ParseObject todo; todo = todos.get(extras.getInt("position")); todo.put("DataI", extras.getString("DataI")); todo.put("DataO", extras.getString("DataO")); todo.put("DataRSSI", extras.getString("DataRSSI")); todo.put("DataSSID", extras.getString("DataSSID")); todo.put("DataTIME", extras.getString("DataTIME")); todo.put("DataRESTRICTED", extras.getString("DataRESTRICTED")); new RemoteDataTask() { protected void doInBackground(Void... params) { try { todo.save(); } catch (ParseException e) { } super.doInBackground(); return; } }.execute(); break; } } @Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); menu.add(0, INSERT_ID, 0, R.string.menu_insert); return result; } @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add(0, DELETE_ID, 0, R.string.menu_delete); } @Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case DELETE_ID: AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); // Delete the remote object final ParseObject todo = todos.get(info.position); new RemoteDataTask() { protected void doInBackground(Void... params) { try { todo.delete(); } catch (ParseException e) { } super.doInBackground(); return; } }.execute(); return true; } return super.onContextItemSelected(item); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case INSERT_ID: createTodo(); return true; } return super.onOptionsItemSelected(item); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Intent i = new Intent(this, CreateTodo.class); i.putExtra("DataI", todos.get(position).getString("DataI").toString()); i.putExtra("DataO", todos.get(position).getString("DataO").toString()); i.putExtra("DataRSSI", todos.get(position).getString("DataRSSI").toString()); i.putExtra("DataSSID", todos.get(position).getString("DataSSID").toString()); i.putExtra("DataTIME", todos.get(position).getString("DataTIME").toString()); i.putExtra("DataRESTRICTED", todos.get(position).getString("DataRESTRICTED").toString()); i.putExtra("position", position); startActivityForResult(i, ACTIVITY_EDIT); } } </code></pre> <p>PROBLEMS</p> <pre><code>Description Resource Path Location Type Void methods cannot return a value ToDoListActivity.java /NFC Linking Manager/src/com/nfc/linkingmanager line 56 Java Problem The return type is incompatible with AsyncTask&lt;Void,Void,Void&gt;.doInBackground(Void[]) ToDoListActivity.java /NFC Linking Manager/src/com/nfc/linkingmanager line 47 Java Problem </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload