Reputation: 31
Well, the title says everything, but there's a little problem, I can't use a fragment or a loader, because I'm developing for android 2.3, so, how can I update just a part of the activity?
Upvotes: 0
Views: 73
Reputation: 194
You can reference the views by ID. As an example to change a EditText you can:
EditText text = (EditText) findViewById(R.id.input);
test.setText("New Text");
Just change the cast to the proper type, so for a button:
Button btn = (Button) findViewById(R.id.button);
So for your code if you have a button with the xml element android:onclick="increment"
you can have a function such as:
public void increment(View view) {
TextView number = (TextView) findViewById(R.id.number);
number.setText(Integer.toString(Integer.parseInt(number.getText()) + 1));
}
Upvotes: 0
Reputation: 6517
You can still use a fragment even in 2.3 by using the android-support-v4 jar
Upvotes: 2