Created
April 25, 2017 23:23
-
-
Save PharcydeTribe/91538cdff916e571ce7856efa29bc9f5 to your computer and use it in GitHub Desktop.
Crashing attempt to set ListView's adapter with SimpleCursorAdapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/activity_translate" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
tools:context="ca.on.sl.comp208.comp208a3aidenscott.Translate"> | |
<ListView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="10dp" | |
android:layout_alignParentBottom="true" | |
android:layout_alignParentStart="true" | |
android:layout_below="@+id/languages" | |
android:id="@+id/lv"> | |
</ListView> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/list_item_layout" | |
android:layout_width="fill_parent" | |
android:layout_height="?android:attr/listPreferredItemHeight" | |
android:padding="6dip" > | |
<TextView | |
android:id="@+id/txt1" | |
android:layout_width="fill_parent" | |
android:layout_height="26dip" | |
android:layout_alignParentBottom="true" | |
android:layout_alignParentRight="true" | |
android:ellipsize="marquee" | |
android:text="Description" | |
android:textSize="12sp" /> | |
<TextView | |
android:id="@+id/txt2" | |
android:layout_width="fill_parent" | |
android:layout_height="26dip" | |
android:layout_alignParentBottom="true" | |
android:layout_alignParentRight="true" | |
android:ellipsize="marquee" | |
android:text="Description" | |
android:textSize="12sp" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x94c8eb20) | |
D/dalvikvm: GC_FOR_ALLOC freed 446K, 11% free 4389K/4892K, paused 2ms, total 3ms | |
D/dalvikvm: GC_FOR_ALLOC freed 512K, 12% free 4389K/4960K, paused 3ms, total 3ms | |
D/dalvikvm: GC_FOR_ALLOC freed 505K, 12% free 4391K/4960K, paused 2ms, total 3ms | |
D/dalvikvm: GC_FOR_ALLOC freed 516K, 12% free 4387K/4960K, paused 3ms, total 3ms | |
D/dalvikvm: GC_FOR_ALLOC freed 508K, 12% free 4389K/4960K, paused 2ms, total 2ms | |
D/dalvikvm: GC_FOR_ALLOC freed 507K, 12% free 4391K/4960K, paused 2ms, total 2ms | |
D/dalvikvm: GC_FOR_ALLOC freed 515K, 12% free 4386K/4960K, paused 2ms, total 2ms | |
D/dalvikvm: GC_FOR_ALLOC freed 508K, 12% free 4389K/4960K, paused 2ms, total 2ms | |
D/dalvikvm: GC_FOR_ALLOC freed 508K, 12% free 4391K/4960K, paused 2ms, total 3ms | |
D/dalvikvm: GC_FOR_ALLOC freed 498K, 12% free 4391K/4960K, paused 3ms, total 3ms | |
D/dalvikvm: GC_FOR_ALLOC freed 515K, 12% free 4387K/4960K, paused 2ms, total 2ms | |
D/dalvikvm: GC_FOR_ALLOC freed 509K, 12% free 4389K/4960K, paused 3ms, total 3ms | |
D/dalvikvm: GC_FOR_ALLOC freed 506K, 12% free 4391K/4960K, paused 3ms, total 3ms | |
I/dalvikvm: threadid=1: stack overflow on call to Ljava/util/Arrays;.checkOffsetAndCount:VIII | |
I/dalvikvm: method requires 16+20+16=52 bytes, fp is 0x88dcd314 (20 left) | |
I/dalvikvm: expanding stack end (0x88dcd300 to 0x88dcd000) | |
I/dalvikvm: Shrank stack (to 0x88dcd300, curFrame is 0x88dcd358) | |
D/dalvikvm: GC_FOR_ALLOC freed 532K, 12% free 4370K/4960K, paused 3ms, total 3ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Translate extends AppCompatActivity { | |
SimpleCursorAdapter sca; | |
ListView lv; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_translate); | |
//lets me see a little more of what's going on | |
final Thread.UncaughtExceptionHandler subclass = Thread.currentThread().getUncaughtExceptionHandler(); | |
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | |
@Override | |
public void uncaughtException(Thread paramThread, Throwable paramThrowable) { | |
Log.getStackTraceString(paramThrowable); | |
subclass.uncaughtException(paramThread, paramThrowable); | |
} | |
}); | |
lv = (ListView) findViewById(R.id.lv); | |
String[] from = {"_id","str"}; | |
int[] to = {R.id.txt1, R.id.txt2}; | |
String[] str = {"_id","str"}; | |
MatrixCursor mc = new MatrixCursor(str); | |
MatrixCursor.RowBuilder rb; | |
rb = mc.newRow(); | |
rb.add("1"); | |
rb.add("thisisastring"); | |
this.sca = new SimpleCursorAdapter(this, R.id.list_item_layout, mc, from, to, 0); | |
lv.setAdapter(this.sca); //crashes upon executing this line | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment