android


Volley Crashing in onResponse When Creating View


This will be brief because I have no clue what the problem is. In my onResponse of a Volley Request I'm creating a TextView. In doing so the application crashes. I can't understand the stack trace because it seems to be 90% assembly (and my assembly knowledge consists of 1s and 0s). Here's a link to the stack (It's about 50000 characters and I have no clue what is relevant in it...): https://justpaste.it/16l9m
And here's the onResponse:
int i = 0;
GridLayout.Spec r = GridLayout.spec(0, 1);
GridLayout.Spec c1 = GridLayout.spec(0, 1);
GridLayout.LayoutParams f1 = new GridLayout.LayoutParams(r, c1);
f1.rightMargin = 250;
GridLayout.Spec c2 = GridLayout.spec(1, 1);
GridLayout.LayoutParams l1 = new GridLayout.LayoutParams(r, c2);
l1.rightMargin = 25;
GridLayout.Spec c3 = GridLayout.spec(2, 1);
GridLayout.LayoutParams p1 = new GridLayout.LayoutParams(r, c3);
p1.rightMargin = 25;
GridLayout.Spec c4 = GridLayout.spec(3, 1);
GridLayout.LayoutParams co = new GridLayout.LayoutParams(r, c4);
co.rightMargin = 25;
GridLayout.Spec c5 = GridLayout.spec(4,1);
GridLayout.LayoutParams d1 = new GridLayout.LayoutParams(r, c5);
TextView firstT = new TextView(context);
firstT.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
firstT.setText("Product");
grid.addView(firstT, f1);
TextView lastT = new TextView(context);
lastT.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
lastT.setText("Quantity");
grid.addView(lastT, l1);
TextView purchasesT = new TextView(context);
purchasesT.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
purchasesT.setText("Price");
grid.addView(purchasesT, p1);
TextView creditsT = new TextView(context);
creditsT.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
creditsT.setText("Credits");
grid.addView(creditsT, co);
/*TextView dateT = new TextView(context);
creditsT.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
creditsT.setText("Date");
grid.addView(dateT, d1);
*/
grid.refreshDrawableState();
try {
while (response.has(String.valueOf(i))) {
GridLayout.Spec row = GridLayout.spec(i + 1, 1);
GridLayout.Spec col1 = GridLayout.spec(0, 1);
GridLayout.LayoutParams f = new GridLayout.LayoutParams(row, col1);
GridLayout.Spec col2 = GridLayout.spec(1, 1);
GridLayout.LayoutParams l = new GridLayout.LayoutParams(row, col2);
GridLayout.Spec col3 = GridLayout.spec(2, 1);
GridLayout.LayoutParams p = new GridLayout.LayoutParams(row, col3);
GridLayout.Spec col4 = GridLayout.spec(3, 1);
GridLayout.LayoutParams c = new GridLayout.LayoutParams(row, col4);
GridLayout.Spec col5 = GridLayout.spec(4, 1);
GridLayout.LayoutParams d = new GridLayout.LayoutParams(row, col5);
TextView first = new TextView(context);
first.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
first.setText(response.getJSONObject(String.valueOf(i)).getString("Product"));
grid.addView(first, f);
TextView last = new TextView(context);
last.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
last.setText(response.getJSONObject(String.valueOf(i)).getString("Quantity"));
grid.addView(last, l);
TextView purchases = new TextView(context);
purchases.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
purchases.setText(response.getJSONObject(String.valueOf(i)).get("Price").toString());
grid.addView(purchases, p);
TextView credits = new TextView(context);
credits.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
credits.setText(response.getJSONObject(String.valueOf(i)).get("Credits").toString());
grid.addView(credits, c);
/*TextView date = new TextView(context);
credits.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
credits.setText(response.getJSONObject(String.valueOf(i++)).get("Date").toString());
grid.addView(date, d);
*/
grid.refreshDrawableState();
}
pd.cancel();
} catch (JSONException e) {
e.printStackTrace();
}
}
It doesn't give the error at the same TextView every time but it's always on the line where I instantiate one the first ones. Lastly, please try not to cringe at the horrible variable names.. I need to fix that.
I mistakenly commented out the section of code containing i++... The while loop was simply never exiting.

Related Links

Updating TextView using handler
Setting onclickListener for google map without overriding the previous one
Why am I getting these compilation errors in my Android application?
Android jar assets
Declaring components in Android crashes program
Android: programmatically adding buttons to a layout
ListView and ReferenceHolder
Android: NoClassDefFound
How do I add a ViewPager as the top item in my ListView
Adwhril with Millinial media,ZestAdz and InMobi is giving errors
how to adjust the width of Android TextView dynamically
Despite changes in code my Android app isn't reinstalling onto my AVD in Eclipse?
Adding EditText to LinearLayout programatically in android
AndEngine Examples not working
Android - Opening Default Music Library Properly
MediaStore not finding all files

Categories

HOME
cygwin
grok
telegram
amp-html
character-encoding
fftw
package
graphics
requirements
javacc
ibeacon-android
fhir
java.util.logging
rtf
tput
comsol
plink
docx
powershell-v5.0
foreign-keys
connector
googlebot
imagemap
href
monit
highstock
dapper-extensions
maze
bulletphysics
android-sharedpreferences
delimiter
cppreference
nsurl
corenlp-server
send
jbutton
android-maps-extensions
latitude-longitude
reason
imagenet
railstutorial.org
health-monitoring
dcmtk
lampp
chai-as-promised
user-defined-fields
dbcontext
rserve
singleinstance
qtranslate
wpas
context-sensitive-grammar
java-6
dt
cpu-cache
juice-ui
watch-os-2
beamer
installshield-2010
simevents
embedding
http-status-code-401
upx
jparsec
httpruntime.cache
dllimport
computer-architecture
lazybones
ess
xvim
rpart
ocra
cakephp-2.7
nodelist
theos
sonarqube-5.0
jama
mobility
ray
radiant
eclipse-kepler
observium
poker
dopostback
midlet
vfs
subgraph
tournament
twitterizer
office-2007
build-environment
silverlight-oob
visualj#
linfu-dynamicproxy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App