I am trying to get the following code(code pulls from cloud) into a method.
ParseQuery<ParseObject> query = ParseQuery.getQuery("Parse name");
query.getInBackground("asdlasdKSas2", new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
//Cost
shirtCost = (TextView)findViewById(R.id.cost1);
int s1 = object.getInt("cost");
shirtCost.setText(s1);
//Name
shirt = (TextView)findViewById(R.id.snack1);
String s2 = object.getString("item");
shirt.setText(s2);
//Desc
shirtdesc = (TextView)findViewById(R.id.snack1description);
String s3 = object.getString("description");
shirtdesc.setText(s3);
} else {
// something went wrong
}
}
});
shirtCost, shirt, & shirtDesc are all TextViews. I want to be able to call a function witch will replace shirt, shirtDesc, and shirtCost with what ever peramiters I put it. Here is what I tried to do (didn't work):
public void setData(String key, String classname, TextView main, TextView cost, TextView desc, <a way to put an android id in replace of the findViewByID()>){
ParseQuery<ParseObject> query = ParseQuery.getQuery(classname);
query.getInBackground(key, new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
//Cost
cost = (TextView)findViewById(R.id.<?>);
int s1 = object.getInt("cost");
cost.setText(s1);
//Name
main = (TextView)findViewById(R.id.snack1);
String s2 = object.getString("item");
main.setText(s2);
//Desc
desc = (TextView)findViewById(R.id. <?>);
String s3 = object.getString("description");
desc.setText(s3);
} else {
// something went wrong
}
}
});
}
Any suggestions would be amazing. A solution would be even better. Hope I went into enough depth for ya'll to understand. Thanks!
So to explain. In summery, this is what I don't understand. look at this method:
public void example(TextView cost, <permeter idk how to pass. keep reading>) {
cost = (TextView)findViewByID(HOW DO I GET THIS ID THROGUH PERIMETER??);}
I need to pass the ID through the parameter, but have absolute no idea.