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

how can android https connection with volley?
$cordovaFile.writeFile () throws an error always in ionic IOS whenever i try to click a picture and send an api request with it in ionic?
Extended Tracking Vuforia Unity3d
Animate Back Arrow for all sub fragments
How to properly hide navigationbar, and the adaptation of different mobile phones?
ScrollView for TabLayout with VIewPager
Get activity instance of MyFirebaseInstanceIDService
Where to put BroadcastReceiver in Android MVP?
how to make textview of the listview clickable
Android Studio emulator is Force Stopping the app when swiped [duplicate]
single tap for more events
How to add file/camera uploading ability to Turbolinks 5 running on android?
what modifications needed to send verification email before creating user in firebase
How to get ascending percentage on ProgressBar connected with CountDownTimer?
How do I exit a fragment and return to my drawer activity using the back button?
AdRequest not resolved, and marked with RED,But the app works fine

Categories

HOME
go
xml
polymer
telegram
phpmyadmin
jmx
oracle-apex-5
graphics
newrelic
entity-framework-core
big-o
tvos
python-multithreading
banner
jtextpane
webix
character
teechart
rcloud
syntaxnet
reactive-programming
siddhi
opengl-es-3.0
datastage
code-generation
enterprise-architect
poedit
roundup
beta
data.stackexchange.com
fat
syntax-highlighting
magento-1.8
angularjs-material
sammy.js
contacts
python-pptx
apiary.io
raft
sim-toolkit
magento-1.9.2.4
docfx
graphhopper
modernizr
sim-card
laravel-elixir
dbnull
getchar
proget
robomongo
yii2-api
insight
subnet
mouseleave
filenet
restore
change-tracking
cudd
autosar
deep
false-sharing
blitline
concept-insights
ascii-art
state-restoration
linklabel
vigenere
django-urls
canalyzer
uncompress
dnssec
mraid
showdialog
paw
tweenlite
solace-mq
embedded-fonts
mbunit
cffile
time.h
scmmanager
octal
booksleeve
onmousemove
pstack
relative
strsep
office-2007
ajax-polling
django-piston
mathematical-notation

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