List of usage examples for android.widget ScrollView addView
@Override public void addView(View child)
From source file:de.gebatzens.ggvertretungsplan.fragment.ExamFragment.java
@Override public void createView(LayoutInflater inflater, ViewGroup view) { ScrollView sv = new ScrollView(getActivity()); sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); sv.setTag("exam_scroll"); ((LinearLayout) view.findViewById(R.id.exam_content)).addView(sv); LinearLayout l = new LinearLayout(getActivity()); l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); l.setOrientation(LinearLayout.VERTICAL); int p = toPixels(6); l.setPadding(p, p, p, p);// w ww . j ava 2 s.c o m sv.addView(l); createTextView(getResources().getString(R.string.my_exams), toPixels(12), inflater, l); for (Exams.ExamItem item : GGApp.GG_APP.exams) { if (GGApp.GG_APP.filters.mainFilter.matches(item)) { CardView cv = createCardItem(item, inflater); if (cv != null) { l.addView(cv); } } } createTextView(getResources().getString(R.string.all_exams), toPixels(12), inflater, l); for (Exams.ExamItem item : GGApp.GG_APP.exams) { CardView cv = createCardItem(item, inflater); if (cv != null) { l.addView(cv); } } cardColorIndex = 0; }
From source file:com.bhb27.isu.Props.java
private void EditProps(String[] props) { LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.setPadding(30, 20, 30, 20); TextView descriptionText = new TextView(getActivity()); descriptionText.setText(getString(R.string.props_any_edit_dialog_summary)); linearLayout.addView(descriptionText); ScrollView scrollView = new ScrollView(getActivity()); scrollView.setPadding(0, 0, 0, 10);//from ww w . j av a2 s . c o m linearLayout.addView(scrollView); LinearLayout editLayout = new LinearLayout(getActivity()); editLayout.setOrientation(LinearLayout.VERTICAL); scrollView.addView(editLayout); final AppCompatEditText[] EditProps = new AppCompatEditText[props.length]; final AppCompatCheckBox[] ForceBP = new AppCompatCheckBox[props.length]; final TextView[] descriptionAboveText = new TextView[props.length]; final TextView[] descriptionBelowText = new TextView[props.length]; for (int i = 0; i < props.length; i++) { descriptionAboveText[i] = new TextView(getActivity()); descriptionAboveText[i].setText(String.format(getString(R.string.empty), props[i])); editLayout.addView(descriptionAboveText[i]); EditProps[i] = new AppCompatEditText(getActivity()); EditProps[i].setText(Tools.getprop(props[i])); editLayout.addView(EditProps[i]); descriptionBelowText[i] = new TextView(getActivity()); descriptionBelowText[i].setText(getString(R.string.props_any_edit_dialog_already_bp)); ForceBP[i] = new AppCompatCheckBox(getActivity()); ForceBP[i].setText(getString(R.string.props_any_edit_dialog_force_bp)); if (Tools.PropIsinbp(props[i], getActivity())) editLayout.addView(descriptionBelowText[i]); else editLayout.addView(ForceBP[i]); } new AlertDialog.Builder(getActivity(), R.style.AlertDialogStyle) .setTitle(getString(R.string.props_any_edit_dialog_title)).setView(linearLayout) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { return; } }).setPositiveButton(getString(R.string.apply), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int id) { String finalmenssage = "\n", edited; for (int i = 0; i < props.length; i++) { edited = EditProps[i].getText().toString(); if (edited.isEmpty()) { finalmenssage = finalmenssage + String.format(getString(R.string.edited_text_ro), props[i]); } else if (edited.equals(Tools.getprop(props[i]))) finalmenssage = finalmenssage + String.format(getString(R.string.edited_text_equals), props[i]); else { if (((AppCompatCheckBox) ForceBP[i]).isChecked()) Tools.resetprop(executableFilePath, props[i], edited, getActivity(), true); else Tools.resetprop(executableFilePath, props[i], edited, getActivity(), false); finalmenssage = finalmenssage + String.format(getString(R.string.edited_text_ok), props[i]); save_prop(props[i], edited); } finalmenssage = finalmenssage + "\n"; } finaldialogro(finalmenssage); return; } }).show(); }
From source file:com.slushpupie.deskclock.DeskClock.java
protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_CHANGELOG: AlertDialog.Builder builder = new AlertDialog.Builder(this); // Standard AlertDialog does not support HTML-style links. // So rebuild the ScrollView->TextView with the appropriate // settings and set the view directly. TextView tv = new TextView(this); tv.setPadding(5, 5, 5, 5);//w w w.j a va 2 s . c o m tv.setLinksClickable(true); tv.setMovementMethod(LinkMovementMethod.getInstance()); tv.setText(R.string.changeLog); tv.setTextAppearance(this, android.R.style.TextAppearance_Medium); ScrollView sv = new ScrollView(this); sv.setPadding(14, 2, 10, 12); sv.addView(tv); builder.setView(sv).setCancelable(false).setTitle(R.string.changeLogTitle) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(DeskClock.this); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("pref_changelog", false); editor.putString("last_changelog", getString(R.string.app_version)); editor.commit(); } }); return builder.create(); default: return null; } }
From source file:eu.geopaparazzi.library.forms.views.GPictureView.java
/** * @param noteId the id of the note this image belows to. * @param fragmentDetail the fragment detail to use. * @param attrs attributes. * @param requestCode the code for starting the activity with result. * @param parentView parent// w ww .j a va 2 s . c om * @param key key * @param value in case of pictures, the value are the ids of the image, semicolonseparated. * @param constraintDescription constraints */ public GPictureView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String key, String value, String constraintDescription) { super(fragmentDetail.getActivity(), attrs); _value = value; final FragmentActivity activity = fragmentDetail.getActivity(); LinearLayout textLayout = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(activity); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); textView.setText(key.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription); textView.setTextColor(activity.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); final Button button = new Button(activity); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); button.setText(R.string.take_picture); textLayout.addView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences); String imageName = ImageUtilities.getCameraImageName(null); Intent cameraIntent = new Intent(activity, CameraActivity.class); cameraIntent.putExtra(LibraryConstants.PREFS_KEY_CAMERA_IMAGENAME, imageName); cameraIntent.putExtra(LibraryConstants.DATABASE_ID, noteId); if (gpsLocation != null) { cameraIntent.putExtra(LibraryConstants.LATITUDE, gpsLocation[1]); cameraIntent.putExtra(LibraryConstants.LONGITUDE, gpsLocation[0]); cameraIntent.putExtra(LibraryConstants.ELEVATION, gpsLocation[2]); } fragmentDetail.startActivityForResult(cameraIntent, requestCode); } }); ScrollView scrollView = new ScrollView(activity); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); scrollView.setLayoutParams(scrollLayoutParams); parentView.addView(scrollView); imageLayout = new LinearLayout(activity); LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); imageLayout.setLayoutParams(imageLayoutParams); imageLayout.setOrientation(LinearLayout.HORIZONTAL); scrollView.addView(imageLayout); try { refresh(activity); } catch (Exception e) { GPLog.error(this, null, e); } }
From source file:com.auth0.android.lock.LockActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!hasValidLaunchConfig()) { return;//from ww w. j a va2 s . co m } getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); Bus lockBus = new Bus(); lockBus.register(this); handler = new Handler(getMainLooper()); setContentView(R.layout.com_auth0_lock_activity_lock); resultMessage = (TextView) findViewById(R.id.com_auth0_lock_result_message); ScrollView rootView = (ScrollView) findViewById(R.id.com_auth0_lock_content); lockView = new ClassicLockView(this, lockBus, options.getTheme()); RelativeLayout.LayoutParams lockViewParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); lockView.setLayoutParams(lockViewParams); rootView.addView(lockView); loginErrorBuilder = new LoginErrorMessageBuilder(R.string.com_auth0_lock_db_login_error_message, R.string.com_auth0_lock_db_login_error_invalid_credentials_message); signUpErrorBuilder = new SignUpErrorMessageBuilder(); lockBus.post(new FetchApplicationEvent()); }
From source file:org.telegram.ui.ChangePhoneHelpActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); TLRPC.User user = UserConfig.getCurrentUser(); String value;//from ww w . jav a 2 s .c o m if (user != null && user.phone != null && user.phone.length() != 0) { value = PhoneFormat.getInstance().format("+" + user.phone); } else { value = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); } actionBar.setTitle(value); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); fragmentView = new RelativeLayout(context); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); RelativeLayout relativeLayout = (RelativeLayout) fragmentView; ScrollView scrollView = new ScrollView(context); relativeLayout.addView(scrollView); RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) scrollView.getLayoutParams(); layoutParams3.width = LayoutHelper.MATCH_PARENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); scrollView.setLayoutParams(layoutParams3); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setPadding(0, AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20)); scrollView.addView(linearLayout); ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) linearLayout.getLayoutParams(); layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT; layoutParams.height = ScrollView.LayoutParams.WRAP_CONTENT; linearLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.phone_change); linearLayout.addView(imageView); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; imageView.setLayoutParams(layoutParams2); TextView textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setGravity(Gravity.CENTER_HORIZONTAL); //textView.setTextColor(0xff212121); try { textView.setText(AndroidUtilities .replaceTags(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp))); } catch (Exception e) { FileLog.e("tmessages", e); textView.setText(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)); } linearLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.leftMargin = AndroidUtilities.dp(20); layoutParams2.rightMargin = AndroidUtilities.dp(20); layoutParams2.topMargin = AndroidUtilities.dp(56); textView.setLayoutParams(layoutParams2); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent) /*0xff4d83b3*/); textView.setText(LocaleController.getString("PhoneNumberChange", R.string.PhoneNumberChange)); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12)); textView.setBackground(context.getDrawable(R.drawable.list_selector)); linearLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.leftMargin = AndroidUtilities.dp(20); layoutParams2.rightMargin = AndroidUtilities.dp(20); layoutParams2.topMargin = AndroidUtilities.dp(46); textView.setLayoutParams(layoutParams2); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("PhoneNumberAlert", R.string.PhoneNumberAlert)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { presentFragment(new ChangePhoneActivity(), true); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } }); return fragmentView; }
From source file:de.gebatzens.ggvertretungsplan.fragment.MensaFragment.java
@Override public void createView(LayoutInflater inflater, ViewGroup view) { Display display = ((WindowManager) getActivity().getApplicationContext() .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); Log.d("Screen orientation", String.valueOf(rotation)); if ((rotation == 3) || (rotation == 1)) { screen_orientation_horizotal = true; } else {//from ww w . ja v a2 s .c o m screen_orientation_horizotal = false; } final ScrollView sv = new ScrollView(getActivity()); sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); sv.setTag("mensa_scroll"); ((LinearLayout) view.findViewById(R.id.mensa_content)).addView(sv); final LinearLayout l = new LinearLayout(getActivity()); l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); l.setOrientation(LinearLayout.VERTICAL); int p = toPixels(6); l.setPadding(p, p, p, p); sv.addView(l); for (Mensa.MensaItem item : GGApp.GG_APP.mensa) { if (!item.isPast()) l.addView(createCardItem(item, inflater)); } }
From source file:com.sastra.app.timetable.TimetableActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.timetable_main); Log.d(TAG, "Entered On Create"); ActionBar Bar = getActionBar();//from ww w . j ava 2 s . c o m Bar.setLogo(R.drawable.ic_launcher_1); //Bar.setTitle(""); // String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/SASTRA Timetable/files/test.txt"; SharedPreferences mPreferences = this.getSharedPreferences("AB", MODE_PRIVATE); boolean firstTime = mPreferences.getBoolean("firstTime", true); if (firstTime) { SharedPreferences.Editor editor = mPreferences.edit(); editor.putBoolean("firstTime", false); editor.commit(); Dialog d2 = new Dialog(this); d2.setTitle("HELP"); d2.setCanceledOnTouchOutside(true); TextView tv = new TextView(this); tv.setText( "This application can be used to store your timetable.First,click on Manage Subjects Icon(Wrench Icon) inorder to add all your subjects.Click on Add Subjects on top and enter the details of your subject.The fields that appear are optional and not manditory.Once you have added all the subjects,go back to the main screen and click on Add Classes icon(Plus Icon) to add the different classes to your timetable.The fields that appear are again optional and all of them need not be filled.You can long press on any particular subject to edit or delete them.You can delete all the informations using Delete All(Garbage Icon) option."); ScrollView sav = new ScrollView(this); sav.addView(tv); LayoutParams lap = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); d2.addContentView(sav, lap); d2.show(); } boolean enabled = true; Bar.setHomeButtonEnabled(enabled); //File database=getApplicationContext().getDatabasePath("massey.db"); // if (database.exists()) { data = new InternalDB(this); // } // add fragments mFragments = new ArrayList<Fragment>(); mFragments.add(Fragment.instantiate(this, MONDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, TUESDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, WEDNESDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, THURSDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, FRIDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, SATURDAYFRAGMENT)); // adapter mAdapter = new MainPagerAdapter(getSupportFragmentManager(), mFragments); // pager mPager = (ViewPager) findViewById(R.id.view_pager); mPager.setAdapter(mAdapter); // indicator mIndicator = (TitlePageIndicator) findViewById(R.id.title_indicator); //mIndicator.setBackgroundColor(0x0106000e); //mIndicator.setFooterColor(0xffffff); mIndicator.setTextColor(0xFF000000); mIndicator.setSelectedColor(0xFF000000); mIndicator.setViewPager(mPager); intent = new Intent(getApplicationContext(), AddSubjects.class);//intent = new Intent(getApplicationContext(), AddSubjects.class); builder = new AlertDialog.Builder(this); builder.setMessage("Are you sure you want to delete all lessons?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { data.open(); data.deleteAllHours(); data.close(); // update(); mAdapter.notifyDataSetChanged(); mAdapter.finishUpdate(mPager); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alert = builder.create(); builder2 = new AlertDialog.Builder(this); builder2.setMessage("Are you sure you want to delete this lesson?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { data.open(); data.deleteHour(OLDSName, OLDHDay, OLDHType, OLDHClass, OLDHStart, OLDHEnd); data.close(); //update(); mAdapter.notifyDataSetChanged(); mAdapter.finishUpdate(mPager); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alert2 = builder2.create(); //added addDialog = new Dialog(this); addDialog.setCancelable(false); action = "insert"; addDialog.setTitle("Add Class"); addDialog.setContentView(R.layout.timetable_addhour); HType = (EditText) addDialog.findViewById(R.id.typeEdit); HClass = (EditText) addDialog.findViewById(R.id.classroomEdit); arraydays = new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; HDay = (Spinner) addDialog.findViewById(R.id.day); arrayadapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, arraydays); arrayadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); HDay.setAdapter(arrayadapter); HDay.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) { selectedDay = arraydays[position]; } public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); fromDialog = new TimePickerDialog(this, fromTimeSetListener, 12, 0, true); toDialog = new TimePickerDialog(this, toTimeSetListener, 12, 0, true); //This place is important. SName = (Spinner) addDialog.findViewById(R.id.SName); SName.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) { selectedSubject = (String) arraySubjects[position]; Log.d("AB", "We are inside the setOnItemSelectedListener for Sname : 264"); Log.d("AB", selectedSubject); } public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); Button buttonFrom = (Button) addDialog.findViewById(R.id.buttonFrom); buttonFrom.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { fromDialog.show(); } }); Button buttonTo = (Button) addDialog.findViewById(R.id.buttonTo); buttonTo.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { toDialog.show(); } }); start = (TextView) addDialog.findViewById(R.id.start); end = (TextView) addDialog.findViewById(R.id.end); Button cancel = (Button) addDialog.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { addDialog.cancel(); fromDialog.updateTime(12, 0); toDialog.updateTime(12, 0); start.setText("--:--"); end.setText("--:--"); HType.setText(null); HClass.setText(null); } }); Button ok = (Button) addDialog.findViewById(R.id.ok); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { int HDay = SDay2IDay(selectedDay); if (action.equals("insert")) { data.open(); data.insertIntoHours(selectedSubject, HDay, HType.getText().toString(), HClass.getText().toString(), start.getText().toString(), end.getText().toString()); data.close(); } else if (action.equals("edit")) { data.open(); data.updateHours(OLDSName, OLDHType, OLDHClass, OLDHDay, OLDHStart, OLDHEnd, selectedSubject, HDay, HType.getText().toString(), HClass.getText().toString(), start.getText().toString(), end.getText().toString()); data.close(); } addDialog.cancel(); fromDialog.updateTime(12, 0); toDialog.updateTime(12, 0); start.setText("--:--"); end.setText("--:--"); HType.setText(null); HClass.setText(null); mAdapter.notifyDataSetChanged(); //update(); mAdapter.finishUpdate(mPager); } }); }
From source file:eu.geopaparazzi.library.forms.views.GSketchView.java
/** * @param noteId the id of the note this image belows to. * @param fragmentDetail the fragment detail to use. * @param attrs attributes. * @param requestCode the code for starting the activity with result. * @param parentView parent/*from w w w . j a va 2 s. com*/ * @param key key * @param value value * @param constraintDescription constraints */ public GSketchView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String key, String value, String constraintDescription) { super(fragmentDetail.getActivity(), attrs); this.noteId = noteId; _value = value; final FragmentActivity activity = fragmentDetail.getActivity(); LinearLayout textLayout = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(activity); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); textView.setText(key.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription); textView.setTextColor(activity.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); final Button button = new Button(activity); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); button.setText(R.string.draw_sketch); textLayout.addView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences); Date currentDate = new Date(); String sketchImageName = ImageUtilities.getSketchImageName(currentDate); File tempDir = ResourcesManager.getInstance(getContext()).getTempDir(); File sketchFile = new File(tempDir, sketchImageName); /* * open markers for new sketch */ MarkersUtilities.launch(fragmentDetail, sketchFile, gpsLocation, requestCode); } catch (Exception e) { e.printStackTrace(); } } }); ScrollView scrollView = new ScrollView(activity); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.FILL_PARENT, 150); scrollView.setLayoutParams(scrollLayoutParams); parentView.addView(scrollView); imageLayout = new LinearLayout(activity); LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); imageLayout.setLayoutParams(imageLayoutParams); // imageLayout.setMinimumHeight(200); imageLayout.setOrientation(LinearLayout.HORIZONTAL); scrollView.addView(imageLayout); // scrollView.setFillViewport(true); try { refresh(activity); } catch (Exception e) { GPLog.error(this, null, e); } }
From source file:br.org.funcate.dynamicforms.views.GSketchView.java
/** * @param noteId the id of the note this image belows to. * @param fragmentDetail the fragment detail to use. * @param attrs attributes. * @param requestCode the code for starting the activity with result. * @param parentView parent// w w w . j a v a 2s. co m * @param label label * @param value value * @param constraintDescription constraints */ public GSketchView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String label, String value, String constraintDescription) { super(fragmentDetail.getActivity(), attrs); this.noteId = noteId; _value = value; final FragmentActivity activity = fragmentDetail.getActivity(); LinearLayout textLayout = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(activity); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription); textView.setTextColor(activity.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); final Button button = new Button(activity); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); button.setText(R.string.draw_sketch); textLayout.addView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences); Date currentDate = new Date(); String sketchImageName = ImageUtilities.getSketchImageName(currentDate); File tempDir = ResourcesManager.getInstance(getContext()).getTempDir(); File sketchFile = new File(tempDir, sketchImageName); /* * open markers for new sketch */ MarkersUtilities.launch(fragmentDetail, sketchFile, gpsLocation, requestCode); } catch (Exception e) { //GPLog.error(this, null, e); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }); ScrollView scrollView = new ScrollView(activity); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, 150); scrollView.setLayoutParams(scrollLayoutParams); parentView.addView(scrollView); imageLayout = new LinearLayout(activity); LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); imageLayout.setLayoutParams(imageLayoutParams); // imageLayout.setMinimumHeight(200); imageLayout.setOrientation(LinearLayout.HORIZONTAL); scrollView.addView(imageLayout); // scrollView.setFillViewport(true); try { refresh(activity); } catch (Exception e) { //GPLog.error(this, null, e); Toast.makeText(this.getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } }