use of android.widget.Button in project dynamic-load-apk by singwhatiwanna.
the class MainActivity method generateContentView.
private View generateContentView(final Context context) {
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
layout.setBackgroundColor(Color.parseColor("#F79AB5"));
Button button = new Button(context);
button.setText("Start TestActivity");
layout.addView(button, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DLIntent intent = new DLIntent(getPackageName(), TestFragmentActivity.class);
// 传递Parcelable类型的数据
intent.putExtra("person", new Person("plugin-a", 22));
intent.putExtra("dl_extra", "from DL framework");
startPluginActivityForResult(intent, 0);
}
});
Button button2 = new Button(context);
button2.setText("Start Service");
layout.addView(button2, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
button2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
DLIntent intent = new DLIntent(getPackageName(), TestService.class);
startPluginService(intent);
}
});
Button button3 = new Button(context);
button3.setText("bind Service");
layout.addView(button3, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
button3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mConnecton == null) {
mConnecton = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
}
public void onServiceConnected(ComponentName name, IBinder binder) {
int sum = ((ITestServiceInterface) binder).sum(5, 5);
Log.e("MainActivity", "onServiceConnected sum(5 + 5) = " + sum);
}
};
}
DLIntent intent = new DLIntent(getPackageName(), TestService.class);
bindPluginService(intent, mConnecton, Context.BIND_AUTO_CREATE);
}
});
Button button4 = new Button(context);
button4.setText("unbind Service");
layout.addView(button4, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
button4.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (mConnecton != null) {
DLIntent intent = new DLIntent(getPackageName(), TestService.class);
unBindPluginService(intent, mConnecton);
mConnecton = null;
}
}
});
return layout;
}
use of android.widget.Button in project platform_frameworks_base by android.
the class SurfaceAndTextureViews method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.surface_texture_views);
final ViewGroup container = (ViewGroup) findViewById(R.id.container);
Button toggleButton = (Button) findViewById(R.id.toggleButton);
mView = new SimpleView(this);
mView.setId(0);
mView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
container.addView(mView);
mSurfaceView = new SimpleSurfaceView(this);
mSurfaceView.setId(1);
mSurfaceView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
container.addView(mSurfaceView);
mTextureView = new SimpleTextureView(this);
mTextureView.setId(2);
mTextureView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
container.addView(mTextureView);
final TransitionSet transition = new TransitionSet();
transition.addTransition(new ChangeBounds()).addTransition(new Crossfade().addTarget(0).addTarget(1).addTarget(2));
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Scene newScene = new Scene(container);
newScene.setEnterAction(new Runnable() {
@Override
public void run() {
if (mView.getWidth() <= SMALL_SIZE) {
mView.setLayoutParams(new LayoutParams(SMALL_SIZE * 2, SMALL_SIZE));
mSurfaceView.setLayoutParams(new LayoutParams(SMALL_SIZE * 2, SMALL_SIZE));
mTextureView.setLayoutParams(new LayoutParams(SMALL_SIZE * 2, SMALL_SIZE));
mView.mColor = SimpleView.LARGE_COLOR;
mSurfaceView.mColor = SimpleSurfaceView.LARGE_COLOR;
mTextureView.mColor = SimpleTextureView.LARGE_COLOR;
} else {
mView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
mSurfaceView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
mTextureView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
mView.mColor = SimpleView.SMALL_COLOR;
mSurfaceView.mColor = SimpleSurfaceView.SMALL_COLOR;
mTextureView.mColor = SimpleTextureView.SMALL_COLOR;
}
}
});
TransitionManager.go(newScene, transition);
}
});
}
use of android.widget.Button in project platform_frameworks_base by android.
the class SurfaceCompositionMeasuringActivity method createButton.
private Button createButton(String caption, LinearLayout layout) {
Button button = new Button(this);
button.setText(caption);
button.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
button.setOnClickListener(this);
layout.addView(button);
return button;
}
use of android.widget.Button in project platform_frameworks_base by android.
the class Reparenting method setupButtons.
private void setupButtons(int startIndex, ViewGroup parent) {
for (int i = startIndex; i < (startIndex + 3); ++i) {
Button button = new Button(this);
button.setText(Integer.toString(i));
button.setOnClickListener(mButtonListener);
parent.addView(button);
}
}
use of android.widget.Button in project platform_frameworks_base by android.
the class VectorCheckbox method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GridLayout container = new GridLayout(this);
container.setColumnCount(5);
container.setBackgroundColor(0xFF888888);
final Button[] bArray = new Button[icon.length];
for (int i = 0; i < icon.length; i++) {
CheckBox checkBox = new CheckBox(this);
bArray[i] = checkBox;
checkBox.setWidth(200);
checkBox.setButtonDrawable(icon[i]);
container.addView(checkBox);
}
setContentView(container);
}
Aggregations