Reputation: 569
The value has been inserted from ANOTHER class. I want edit the TextEdit to be this value.
public class Second extends Activity {
TextView reslt;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
reslt = (TextView) findViewById(R.id.tvResult);
}
public static void insert(int firstResult) {
// TODO Auto-generated method stub
Someone help please?
I'm trying to make Integer, "firstResult" the TextView, "reslt".
This is where I inserted the integer from:
public class DataHelper extends Activity{
public static void insert(String firstFB, String firstRL) {
// TODO Auto-generated method stub
Integer a = new Integer(firstFB).intValue();
Integer b = new Integer(firstRL).intValue();
int firstResult = a / b;
Second.insert(firstResult);
I have tried using "reslt.editText(firstResult);" under "public static void insert" but it gave me an error saying I cannot make a static reference to a non-static field result.
Any help will be valued. I am a newbie.
Upvotes: 0
Views: 149
Reputation: 28697
Think of "static" as defining a single, global reference. However, you may have multiple instances of your "Second" class, each with multiple TextViews. As such, the compiler has no way of knowing which reslt
you want to update with the text.
You can probably get this to compile by changing your TextView reslt;' line to
static TextView reslt;' - but this likely won't be exactly what you want. Instead, you probably should remove static
from your insert method, and keep a reference to the instance of your "Second" class that you want to insert to.
Upvotes: 1