Skip to content

Commit

Permalink
example: Add "switch activity" and "refresh" buttons to UI
Browse files Browse the repository at this point in the history
Signed-off-by: Jorrit Jongma <[email protected]>
  • Loading branch information
cernekee authored and Chainfire committed Jul 31, 2013
1 parent 3cf1e9b commit 4faf660
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
21 changes: 21 additions & 0 deletions libsuperuser_example/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,25 @@
</LinearLayout>
</ScrollView>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<Button
android:id="@+id/switch_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />

<Button
android:id="@+id/refresh_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/refresh" />

</LinearLayout>

</LinearLayout>
5 changes: 4 additions & 1 deletion libsuperuser_example/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<resources>
<string name="app_name">libsuperuser_example</string>
</resources>
<string name="enable_interactive_mode">Enable Interactive Mode</string>
<string name="disable_interactive_mode">Disable Interactive Mode</string>
<string name="refresh">Refresh</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;
import android.widget.Button;

public class MainActivity extends Activity {
private class Startup extends AsyncTask<Void, Void, Void> {
Expand Down Expand Up @@ -98,7 +101,27 @@ protected void onPostExecute(Void result) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


// mode switch button
Button button = (Button)findViewById(R.id.switch_button);
button.setText(R.string.enable_interactive_mode);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(v.getContext(), InteractiveActivity.class));
finish();
}
});

// refresh button
((Button)findViewById(R.id.refresh_button)).
setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
(new Startup()).setContext(v.getContext()).execute();
}
});

// Let's do some background stuff
(new Startup()).setContext(this).execute();
}
Expand Down

0 comments on commit 4faf660

Please sign in to comment.