Search in sources :

Example 36 with LinearLayout

use of android.widget.LinearLayout 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;
}
Also used : ServiceConnection(android.content.ServiceConnection) LayoutParams(android.view.ViewGroup.LayoutParams) View(android.view.View) IBinder(android.os.IBinder) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ComponentName(android.content.ComponentName) ITestServiceInterface(com.ryg.dynamicload.service.ITestServiceInterface) DLIntent(com.ryg.dynamicload.internal.DLIntent) LinearLayout(android.widget.LinearLayout)

Example 37 with LinearLayout

use of android.widget.LinearLayout in project platform_frameworks_base by android.

the class ManyEditTextActivityScrollResize method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mRootView = new ScrollView(this);
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < NUM_EDIT_TEXTS; i++) {
        final EditText editText = new EditText(this);
        editText.setText(String.valueOf(i));
        editText.setId(i);
        layout.addView(editText);
    }
    ((ScrollView) mRootView).addView(layout);
    setContentView(mRootView);
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
Also used : EditText(android.widget.EditText) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout)

Example 38 with LinearLayout

use of android.widget.LinearLayout in project platform_frameworks_base by android.

the class OneEditTextActivitySelected method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    mRootView = new ScrollView(this);
    EditText editText = new EditText(this);
    editText.requestFocus();
    mDefaultFocusedView = editText;
    layout.addView(editText);
    ((ScrollView) mRootView).addView(layout);
    setContentView(mRootView);
    // set to resize so IME is always shown (and also so
    // ImfBaseTestCase#destructiveCheckImeInitialState thinks it should always be shown
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
Also used : EditText(android.widget.EditText) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout)

Example 39 with LinearLayout

use of android.widget.LinearLayout in project platform_frameworks_base by android.

the class TransformTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setTitle(R.string.act_title);
    LinearLayout root = new LinearLayout(this);
    root.setOrientation(LinearLayout.VERTICAL);
    TransformView view = new TransformView(getApplicationContext());
    Drawable drawable = getResources().getDrawable(R.drawable.logo);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicWidth());
    view.setDrawable(drawable);
    root.addView(view);
    setContentView(root);
}
Also used : Drawable(android.graphics.drawable.Drawable) LinearLayout(android.widget.LinearLayout)

Example 40 with LinearLayout

use of android.widget.LinearLayout 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;
}
Also used : Button(android.widget.Button) LinearLayout(android.widget.LinearLayout)

Aggregations

LinearLayout (android.widget.LinearLayout)1205 View (android.view.View)473 TextView (android.widget.TextView)455 ViewGroup (android.view.ViewGroup)203 ImageView (android.widget.ImageView)196 Button (android.widget.Button)167 ScrollView (android.widget.ScrollView)125 ListView (android.widget.ListView)100 LayoutInflater (android.view.LayoutInflater)90 FrameLayout (android.widget.FrameLayout)85 Context (android.content.Context)80 AdapterView (android.widget.AdapterView)74 EditText (android.widget.EditText)74 Intent (android.content.Intent)66 AbsListView (android.widget.AbsListView)58 LayoutParams (android.widget.LinearLayout.LayoutParams)48 RelativeLayout (android.widget.RelativeLayout)48 Bitmap (android.graphics.Bitmap)46 OnClickListener (android.view.View.OnClickListener)44 Drawable (android.graphics.drawable.Drawable)42