List of usage examples for android.widget LinearLayout LinearLayout
public LinearLayout(Context context)
From source file:com.example.meetingapp.ShowDetailsFragment.java
/** * Adds an image to the HorizontalScrollView. * @param image Image to be added to the HorizontalScrollView. *//* w w w . j a va 2 s . c o m*/ private void addImage(Bitmap image) { LinearLayout layout = new LinearLayout(getActivity()); layout.setGravity(Gravity.CENTER); /* Set parameters - we want a small divider of 3 pixels so we can * easily distinguish different photos. */ LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.setMargins(3, 0, 0, 0); params.gravity = Gravity.CENTER; ImageView imageView = new ImageView(getActivity()); imageView.setScaleType(ScaleType.CENTER); imageView.setImageBitmap(image); imageView.setLayoutParams(params); layout.addView(imageView); mPhotosView.addView(layout); }
From source file:brostore.maquillage.custom.PagerSlidingTabStrip.java
private void addCustomTextTab(final int position, String title) { LinearLayout conteneur = new LinearLayout(getContext()); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); conteneur.setOrientation(LinearLayout.HORIZONTAL); conteneur.setGravity(Gravity.CENTER); TextView tab = new TextView(getContext()); TextView tabCust = new TextView(getContext()); //tabCust.setBackgroundResource(R.drawable.live_nombre); tabCust.setGravity(Gravity.CENTER);//from w w w. jav a2 s . co m tabCust.setTextColor(Color.WHITE); tabCust.setTypeface(tabTypeface); tabCust.setTextSize(11); tabCust.setVisibility(View.GONE); int fiveDip = Utils.convertDpToPixel(5, getResources()); tabCust.setPadding(fiveDip, 0, fiveDip, 0); tabCust.setText("0"); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); conteneur.addView(tab, param); param.leftMargin = Utils.convertDpToPixel(10, getResources()); conteneur.addView(tabCust, param); addTab(position, conteneur); }
From source file:com.app.plugins.childBrowser.ChildBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject // w w w . ja va2 s.c o m */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", false); } final WebView parent = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { public void run() { dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_Black_NoTitleBar_Fullscreen); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); //LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); //LinearLayout.LayoutParams forwardParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); //LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT, 1.0f); LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams wvParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); LinearLayout toolbar = new LinearLayout(cordova.getActivity()); toolbar.setOrientation(LinearLayout.HORIZONTAL); /* ImageButton back = new ImageButton((Context) ctx); back.getBackground().setAlpha(0); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); back.setId(1); try { back.setImageBitmap(loadDrawable("plugins/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setLayoutParams(backParams); ImageButton forward = new ImageButton((Context) ctx); forward.getBackground().setAlpha(0); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); forward.setId(2); try { forward.setImageBitmap(loadDrawable("plugins/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setLayoutParams(forwardParams); */ /* edittext = new EditText((Context) ctx); edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); edittext.setId(3); edittext.setSingleLine(true); edittext.setText(url); edittext.setLayoutParams(editParams); */ //edittext = new EditText((Context) ctx); //edittext.setVisibility(View.GONE); LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT, 1.0f); TextView title = new TextView(cordova.getActivity()); title.setId(1); title.setLayoutParams(titleParams); title.setGravity(Gravity.CENTER_VERTICAL); title.setTypeface(null, Typeface.BOLD); ImageButton close = new ImageButton(cordova.getActivity()); close.getBackground().setAlpha(0); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); close.setId(4); try { close.setImageBitmap(loadDrawable("plugins/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setLayoutParams(closeParams); childWebView = new WebView(cordova.getActivity()); childWebView.getSettings().setJavaScriptEnabled(true); childWebView.getSettings().setBuiltInZoomControls(true); WebViewClient client = new ChildBrowserClient(parent, ctx, title/*, edittext*/); childWebView.setWebViewClient(client); childWebView.loadUrl(url); childWebView.setId(5); childWebView.setInitialScale(0); childWebView.setLayoutParams(wvParams); childWebView.requestFocus(); childWebView.requestFocusFromTouch(); //toolbar.addView(back); //toolbar.addView(forward); //toolbar.addView(edittext); toolbar.addView(close); toolbar.addView(title); if (getShowLocationBar()) { main.addView(toolbar); } main.addView(childWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; lp.verticalMargin = 0f; lp.horizontalMargin = 0f; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = cordova.getActivity().getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java
/** * ?//from w w w. j a v a 2s .co m */ private ViewGroup getTabsLayout() { if (tabsLayout == null) { if (getChildCount() > 0) { tabsLayout = (ViewGroup) getChildAt(0); } else { removeAllViews(); tabsLayout = new LinearLayout(getContext()); addView(tabsLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } } return tabsLayout; }
From source file:com.aware.ui.ESM_UI.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // getActivity().getWindow().setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); builder = new AlertDialog.Builder(getActivity()); inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); TAG = Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG).length() > 0 ? Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG) : TAG;/*from ww w . j a v a 2 s . co m*/ Cursor visible_esm = getActivity().getContentResolver().query(ESM_Data.CONTENT_URI, null, ESM_Data.STATUS + "=" + ESM.STATUS_NEW, null, ESM_Data.TIMESTAMP + " ASC LIMIT 1"); if (visible_esm != null && visible_esm.moveToFirst()) { esm_id = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data._ID)); //Fixed: set the esm as not new anymore, to avoid displaying the same ESM twice due to changes in orientation ContentValues update_state = new ContentValues(); update_state.put(ESM_Data.STATUS, ESM.STATUS_VISIBLE); getActivity().getContentResolver().update(ESM_Data.CONTENT_URI, update_state, ESM_Data._ID + "=" + esm_id, null); esm_type = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.TYPE)); expires_seconds = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.EXPIRATION_THREASHOLD)); builder.setTitle(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.TITLE))); View ui = null; switch (esm_type) { case ESM.TYPE_ESM_TEXT: ui = inflater.inflate(R.layout.esm_text, null); break; case ESM.TYPE_ESM_RADIO: ui = inflater.inflate(R.layout.esm_radio, null); break; case ESM.TYPE_ESM_CHECKBOX: ui = inflater.inflate(R.layout.esm_checkbox, null); break; case ESM.TYPE_ESM_LIKERT: ui = inflater.inflate(R.layout.esm_likert, null); break; case ESM.TYPE_ESM_QUICK_ANSWERS: ui = inflater.inflate(R.layout.esm_quick, null); break; } final View layout = ui; builder.setView(layout); current_dialog = builder.create(); sContext = current_dialog.getContext(); TextView esm_instructions = (TextView) layout.findViewById(R.id.esm_instructions); esm_instructions.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.INSTRUCTIONS))); switch (esm_type) { case ESM.TYPE_ESM_TEXT: final EditText feedback = (EditText) layout.findViewById(R.id.esm_feedback); Button cancel_text = (Button) layout.findViewById(R.id.esm_cancel); cancel_text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0); current_dialog.cancel(); } }); Button submit_text = (Button) layout.findViewById(R.id.esm_submit); submit_text.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0); if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.ANSWER, feedback.getText().toString()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); break; case ESM.TYPE_ESM_RADIO: try { final RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio); final JSONArray radios = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.RADIOS))); for (int i = 0; i < radios.length(); i++) { final RadioButton radioOption = new RadioButton(getActivity()); radioOption.setId(i); radioOption.setText(radios.getString(i)); radioOptions.addView(radioOption); if (radios.getString(i).equals("Other")) { radioOption.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog editOther = new Dialog(getActivity()); editOther.setTitle("Can you be more specific, please?"); editOther.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); editOther.getWindow().setGravity(Gravity.TOP); editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout editor = new LinearLayout(getActivity()); editor.setOrientation(LinearLayout.VERTICAL); editOther.setContentView(editor); editOther.show(); final EditText otherText = new EditText(getActivity()); editor.addView(otherText); Button confirm = new Button(getActivity()); confirm.setText("OK"); confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (otherText.length() > 0) radioOption.setText(otherText.getText()); inputManager.hideSoftInputFromWindow(otherText.getWindowToken(), 0); editOther.dismiss(); } }); editor.addView(confirm); } }); } } Button cancel_radio = (Button) layout.findViewById(R.id.esm_cancel); cancel_radio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit_radio = (Button) layout.findViewById(R.id.esm_submit); submit_radio.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_radio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio); if (radioOptions.getCheckedRadioButtonId() != -1) { RadioButton selected = (RadioButton) radioOptions .getChildAt(radioOptions.getCheckedRadioButtonId()); rowData.put(ESM_Data.ANSWER, selected.getText().toString()); } rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); } catch (JSONException e) { e.printStackTrace(); } break; case ESM.TYPE_ESM_CHECKBOX: try { final LinearLayout checkboxes = (LinearLayout) layout.findViewById(R.id.esm_checkboxes); final JSONArray checks = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.CHECKBOXES))); for (int i = 0; i < checks.length(); i++) { final CheckBox checked = new CheckBox(getActivity()); checked.setText(checks.getString(i)); checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (buttonView.getText().equals("Other")) { checked.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog editOther = new Dialog(getActivity()); editOther.setTitle("Can you be more specific, please?"); editOther.getWindow() .setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); editOther.getWindow().setGravity(Gravity.TOP); editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout editor = new LinearLayout(getActivity()); editor.setOrientation(LinearLayout.VERTICAL); editOther.setContentView(editor); editOther.show(); final EditText otherText = new EditText(getActivity()); editor.addView(otherText); Button confirm = new Button(getActivity()); confirm.setText("OK"); confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (otherText.length() > 0) { inputManager.hideSoftInputFromWindow( otherText.getWindowToken(), 0); selected_options .remove(buttonView.getText().toString()); checked.setText(otherText.getText()); selected_options.add(otherText.getText().toString()); } editOther.dismiss(); } }); editor.addView(confirm); } }); } else { selected_options.add(buttonView.getText().toString()); } } else { selected_options.remove(buttonView.getText().toString()); } } }); checkboxes.addView(checked); } Button cancel_checkbox = (Button) layout.findViewById(R.id.esm_cancel); cancel_checkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit_checkbox = (Button) layout.findViewById(R.id.esm_submit); submit_checkbox.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_checkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); if (selected_options.size() > 0) { rowData.put(ESM_Data.ANSWER, selected_options.toString()); } rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); } catch (JSONException e) { e.printStackTrace(); } break; case ESM.TYPE_ESM_LIKERT: final RatingBar ratingBar = (RatingBar) layout.findViewById(R.id.esm_likert); ratingBar.setMax(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX))); ratingBar.setStepSize( (float) visible_esm.getDouble(visible_esm.getColumnIndex(ESM_Data.LIKERT_STEP))); ratingBar.setNumStars(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX))); TextView min_label = (TextView) layout.findViewById(R.id.esm_min); min_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MIN_LABEL))); TextView max_label = (TextView) layout.findViewById(R.id.esm_max); max_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX_LABEL))); Button cancel = (Button) layout.findViewById(R.id.esm_cancel); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit = (Button) layout.findViewById(R.id.esm_submit); submit.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.ANSWER, ratingBar.getRating()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); break; case ESM.TYPE_ESM_QUICK_ANSWERS: try { final JSONArray answers = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.QUICK_ANSWERS))); final LinearLayout answersHolder = (LinearLayout) layout.findViewById(R.id.esm_answers); //If we have more than 3 possibilities, better that the UI is vertical for UX if (answers.length() > 3) { answersHolder.setOrientation(LinearLayout.VERTICAL); } for (int i = 0; i < answers.length(); i++) { final Button answer = new Button(getActivity()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); answer.setLayoutParams(params); answer.setText(answers.getString(i)); answer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); rowData.put(ESM_Data.ANSWER, (String) answer.getText()); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); answersHolder.addView(answer); } } catch (JSONException e) { e.printStackTrace(); } break; } } if (visible_esm != null && !visible_esm.isClosed()) visible_esm.close(); //Start dialog visibility threshold if (expires_seconds > 0) { expire_monitor = new ESMExpireMonitor(System.currentTimeMillis(), expires_seconds, esm_id); expire_monitor.execute(); } //Fixed: doesn't dismiss the dialog if touched outside or ghost touches current_dialog.setCanceledOnTouchOutside(false); return current_dialog; }
From source file:com.google.code.twisty.Twisty.java
/** Called when activity is first created. */ @Override//from w w w .j ava 2 s. c om public void onCreate(Bundle icicle) { super.onCreate(icicle); // requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_ACTION_BAR); // Map our built-in game resources to real filenames builtinGames.clear(); builtinGames.put(R.raw.violet, "violet.z8"); builtinGames.put(R.raw.rover, "rover.gblorb"); builtinGames.put(R.raw.glulxercise, "glulxercise.ulx"); builtinGames.put(R.raw.windowtest, "windowtest.ulx"); UISync.setInstance(this); // An imageview to show the twisty icon iv = new ImageView(this); iv.setBackgroundColor(0xffffff); iv.setImageResource(R.drawable.app_icon); iv.setAdjustViewBounds(true); iv.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); // The main 'welcome screen' window from which games are launched. tv = new TextBufferView(this); mainWin = new TextBufferIO(tv, new StyleManager()); //final GlkEventQueue eventQueue = null; tv.setFocusableInTouchMode(true); // The Glk window layout manager glkLayout = new GlkLayout(this); // put it all together ll = new LinearLayout(this); ll.setBackgroundColor(Color.argb(0xFF, 0xFE, 0xFF, 0xCC)); ll.setOrientation(android.widget.LinearLayout.VERTICAL); ll.addView(iv); ll.addView(tv); glkLayout.setVisibility(View.GONE); ll.addView(glkLayout); setContentView(ll); dialog_handler = new DialogHandler(this); terp_handler = new TerpHandler(this); // Ensure we can write story files and save games to external storage checkWritePermission(); Uri dataSource = this.getIntent().getData(); if (dataSource != null) { /* Suck down the URI we received to sdcard, launch terp on it. */ try { startTerp(dataSource); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } } else { printWelcomeMessage(); } }
From source file:com.astuetz.PagerSlidingTitleIconTabStrip.java
private void addTextIconTab(final int position, String title, int resId) { if (resId == TitleIconTabProvider.NONE_ICON) { addTextTab(position, title);//from ww w. j av a 2 s . co m return; } TextView tab = new TextView(getContext()); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); ImageView icon = new ImageView(getContext()); icon.setImageResource(resId); LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.addView(icon, defaultTabLayoutParams); linearLayout.addView(tab, defaultTabLayoutParams); addTab(position, linearLayout); }
From source file:com.google.android.gcm.demo.ui.NetworkSchedulerFragment.java
@Override public void refresh() { FrameLayout tasksView = (FrameLayout) getActivity().findViewById(R.id.scheduler_tasks); // the view might have been destroyed, in which case we don't do anything if (tasksView != null) { float density = getActivity().getResources().getDisplayMetrics().density; SimpleArrayMap<String, TaskTracker> tasks = mTasks.getTasks(); LinearLayout tasksList = new LinearLayout(getActivity()); tasksList.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < tasks.size(); i++) { final TaskTracker task = tasks.valueAt(i); CardView taskCard = (CardView) getActivity().getLayoutInflater().inflate(R.layout.widget_task, tasksList, false);// w ww . j av a 2 s .c om ImageView taskIcon = (ImageView) taskCard.findViewById(R.id.task_icon); taskIcon.setImageResource(R.drawable.check_circle_grey600); taskIcon.setPadding(0, 0, (int) (8 * density), 0); TextView taskLabel = (TextView) taskCard.findViewById(R.id.task_title); TextView taskParams = (TextView) taskCard.findViewById(R.id.task_params); if (task.period == 0) { taskLabel.setText(getString(R.string.scheduler_oneoff, task.tag)); taskParams.setText(getString(R.string.scheduler_oneoff_params, task.windowStartElapsedSecs, task.windowStopElapsedSecs)); } else { taskLabel.setText(getString(R.string.scheduler_periodic, task.tag)); taskParams.setText(getString(R.string.scheduler_periodic_params, task.period, task.flex)); } TextView taskCreatedAt = (TextView) taskCard.findViewById(R.id.task_created_at); taskCreatedAt.setText(getString(R.string.scheduler_secs_ago, DateUtils .formatElapsedTime(SystemClock.elapsedRealtime() / 1000 - task.createdAtElapsedSecs))); TextView lastExecuted = (TextView) taskCard.findViewById(R.id.task_last_exec); if (task.executionTimes.isEmpty()) { lastExecuted.setText(getString(R.string.scheduler_na)); } else { long lastExecTime = task.executionTimes.get(task.executionTimes.size() - 1); lastExecuted.setText(getString(R.string.scheduler_secs_ago, DateUtils.formatElapsedTime(SystemClock.elapsedRealtime() / 1000 - lastExecTime))); } TextView state = (TextView) taskCard.findViewById(R.id.task_state); if (task.isCancelled()) { state.setText(getString(R.string.scheduler_cancelled)); } else if (task.isExecuted()) { state.setText(getString(R.string.scheduler_executed)); } else { state.setText(getString(R.string.scheduler_pending)); } Button cancel = (Button) taskCard.findViewById(R.id.task_cancel); cancel.setVisibility(View.VISIBLE); cancel.setText(R.string.scheduler_cancel); Button delete = (Button) taskCard.findViewById(R.id.task_delete); delete.setVisibility(View.VISIBLE); delete.setText(R.string.scheduler_delete); if (!task.isCancelled() && (!task.isExecuted() || task.period != 0)) { cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { cancelTask(task.tag); refresh(); } }); cancel.setEnabled(true); delete.setEnabled(false); } else { cancel.setEnabled(false); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mTasks.deleteTask(task.tag); refresh(); } }); delete.setEnabled(true); } tasksList.addView(taskCard); } tasksView.removeAllViews(); tasksView.addView(tasksList); } }
From source file:com.efan.notlonely_android.view.PagerSlidingTabStrip.java
private ViewGroup getTabsLayout() { if (tabsLayout == null) { if (getChildCount() > 0) { tabsLayout = (ViewGroup) getChildAt(0); } else {/*w w w. j a v a 2s .c o m*/ removeAllViews(); LinearLayout tabsLayout = new LinearLayout(getContext()); tabsLayout.setGravity(Gravity.CENTER_VERTICAL); this.tabsLayout = tabsLayout; addView(tabsLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL)); } } return tabsLayout; }
From source file:com.haomee.view.PagerSlidingTabStrip.java
private void addTextIconTab(final int position, String title, int resId) { if (resId == TitleIconTabProvider.NONE_ICON) { addTextTab(position, title);/*w w w . j a v a2 s. c om*/ return; } TextView tab = new TextView(getContext()); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); ImageView icon = new ImageView(getContext()); icon.setImageResource(resId); LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.addView(tab, defaultTabLayoutParams); linearLayout.addView(icon, defaultTabLayoutParams); addTab(position, linearLayout); }