List of usage examples for android.widget LinearLayout getChildAt
public View getChildAt(int index)
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * Recording time ASYNCHRONOUSLY//from ww w.ja v a2 s. co m * * @param v */ public void onClickRecord(View v) { LinearLayout llTimePicker = (LinearLayout) v.getParent(); LinearLayout lllFrag = (LinearLayout) llTimePicker.getParent(); LinearLayout llTime = (LinearLayout) llTimePicker.findViewById(R.id.llTimePicker); TimePicker tp = (TimePicker) llTime.findViewById(R.id.tpTask); Integer oiHour = tp.getCurrentHour(); Integer oiMin = tp.getCurrentMinute(); DateUtils du = new DateUtils(); long lmills = du.toMills(oiHour, oiMin); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckIn = new Date().getTime(); long lCheckOut = lCheckIn + lmills; // Save data into both databases Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_ASYNCHRONOUS); recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT) .show(); }
From source file:org.ale.scanner.zotero.BibDetailJSONAdapter.java
public void fillLinearLayout(LinearLayout layout) { int childCount = layout.getChildCount(); // Layout might not be the view we used last time, so // remove any views we won't need if (mNumFilledFields < childCount) { layout.removeViews(mNumFilledFields, layout.getChildCount() - mNumFilledFields); }//www . ja v a 2 s .c om // Edit any of the already attached views for (int entry = 0; entry < mNumFilledFields; entry++) { if (entry < childCount) { View v = layout.getChildAt(entry); getView(entry, v, layout); } else { layout.addView(getView(entry, null, layout)); } } }
From source file:biz.incomsystems.fwknop2.ConfigDetailFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // This handles the qrcode results if (requestCode == 0) { if (resultCode == Activity.RESULT_OK) { String contents = data.getStringExtra("SCAN_RESULT"); for (String stanzas : contents.split(" ")) { String[] tmp = stanzas.split(":"); if (tmp[0].equalsIgnoreCase("KEY_BASE64")) { txt_KEY.setText(tmp[1]); chkb64key.setChecked(true); } else if (tmp[0].equalsIgnoreCase("KEY")) { txt_KEY.setText(tmp[1]); chkb64key.setChecked(false); } else if (tmp[0].equalsIgnoreCase("HMAC_KEY_BASE64")) { txt_HMAC.setText(tmp[1]); chkb64hmac.setChecked(true); } else if (tmp[0].equalsIgnoreCase("HMAC_KEY")) { txt_HMAC.setText(tmp[1]); chkb64hmac.setChecked(false); }// w ww. j ava 2 s.c om } // end for loop } if (resultCode == Activity.RESULT_CANCELED) { //handle cancel Context context = getActivity(); CharSequence text = " QR Code Canceled"; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); LinearLayout toastLayout = (LinearLayout) toast.getView(); TextView toastTV = (TextView) toastLayout.getChildAt(0); toastTV.setTextSize(30); toast.show(); } } }
From source file:com.flowzr.activity.RecurActivity.java
private View selectInLayout(LinearLayout layout, Object tag) { View selected = null;// w w w . j a v a 2 s .c o m int count = layout.getChildCount(); for (int i = 0; i < count; i++) { View v = layout.getChildAt(i); if (tag == v.getTag()) { selected = v; } else { v.setVisibility(View.GONE); } } if (selected != null) { selected.setVisibility(View.VISIBLE); } return selected; }
From source file:ng.kingsley.android.widget.CollectionView.java
private View recycleItemRow(View convertView, RowComputeResult rowInfo) { int i;/*from w w w.j ava2s .c o m*/ LinearLayout ll = (LinearLayout) convertView; for (i = 0; i < rowInfo.group.mDisplayCols; i++) { View view = ll.getChildAt(i); View newView = getItemView(rowInfo, i, view, ll); if (view != newView) { LinearLayout.LayoutParams thisViewParams = setupLayoutParams(newView); ll.removeViewAt(i); ll.addView(newView, i, thisViewParams); } } return ll; }
From source file:org.smap.smapTask.android.activities.MainTabsActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // must be at the beginning of any activity that can be called from an external intent try {//from w w w . j av a2 s . c o m Collect.createODKDirs(); } catch (RuntimeException e) { createErrorDialog(e.getMessage(), true); return; } setContentView(R.layout.main_tabs); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; Intent intent; tabHost.setBackgroundColor(Color.WHITE); tabHost.getTabWidget().setBackgroundColor(Color.DKGRAY); // Initialise a TabSpec and intent for each tab and add it to the TabHost intent = new Intent().setClass(this, MainListActivity.class); spec = tabHost.newTabSpec("taskList").setIndicator(getString(R.string.smap_taskList)).setContent(intent); tabHost.addTab(spec); /* * Initialise a Map tab */ Log.i("trial", "Creating Maps Activity"); intent = new Intent().setClass(this, MapsActivity.class); spec = tabHost.newTabSpec("taskMap").setIndicator(getString(R.string.smap_taskMap)).setContent(intent); tabHost.addTab(spec); // hack to set font size LinearLayout ll = (LinearLayout) tabHost.getChildAt(0); TabWidget tw = (TabWidget) ll.getChildAt(0); int fontsize = Collect.getQuestionFontsize(); ViewGroup rllf = (ViewGroup) tw.getChildAt(0); mTVFF = getTextViewChild(rllf); if (mTVFF != null) { mTVFF.setTextSize(fontsize); mTVFF.setTextColor(Color.WHITE); mTVFF.setPadding(0, 0, 0, 6); } ViewGroup rlrf = (ViewGroup) tw.getChildAt(1); mTVDF = getTextViewChild(rlrf); if (mTVDF != null) { mTVDF.setTextSize(fontsize); mTVDF.setTextColor(Color.WHITE); mTVDF.setPadding(0, 0, 0, 6); } }
From source file:com.android.together.BaseActivity.java
protected void initMenu() { menu = new SlidingMenu(this);//newgetSlidingMenu menu.setMode(SlidingMenu.LEFT);//from ww w.j a v a 2 s .c o m menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); //menu.setShadowDrawable(R.drawable.shadow); //menu.setShadowWidthRes(R.dimen.shadow_width); //menu.setBehindOffsetRes(R.dimen.slidingmenu_offset); menu.setBehindWidth(mScreenWidth / 10 * 7);//SlidingMenu menu.setFadeDegree(0.5f); menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);// menu.setMenu(R.layout.menu_layout);//layout //menu.setSecondaryMenu(R.layout.menu_layout);//layout //menu.setBehindCanvasTransformer(mTransformer); menuItemClickListner = new MyMenuItemClickListner(); LinearLayout layout_item = (LinearLayout) menu.findViewById(R.id.layout_item); for (int i = 0; i < layout_item.getChildCount(); i++) { LinearLayout item = (LinearLayout) layout_item.getChildAt(i); item.setOnClickListener(menuItemClickListner); } }
From source file:app.jorge.mobile.com.transportalert.ScrollingActivity.java
@Override public void onResponse(Response<List<StatusLine>> response, Retrofit retrofit) { if (response.isSuccess()) { tubeStatus = new HashMap<>(); int size = response.body().size(); for (int i = 0; i < size; i++) { StatusLine statusLine = response.body().get(i); String nameKey = statusLine.getName(); LineStatuses lineStatuses = statusLine.getLineStatuses().get(0); //String status =response.body().get(i).getLineStatuses().get(0).getStatusSeverityDescription(); tubeStatus.put(nameKey, lineStatuses); }/*w w w .ja v a2 s .co m*/ //String name=response.body().get(0).getName(); //String status =response.body().get(0).getLineStatuses().get(0).getStatusSeverityDescription(); // Toast.makeText( getContext(), "You Clicked hey "+ status, Toast.LENGTH_SHORT).show(); LinearLayout item = (LinearLayout) findViewById(R.id.rv); int childcount = item.getChildCount(); for (int i = 0; i < childcount; i++) { View child = item.getChildAt(i); TextView lineName = (TextView) child.findViewById(R.id.tubeName); String line_id = lineName.getText().toString(); String message = tubeStatus.get(line_id).getStatusSeverityDescription(); if (message != null) { TextView text = (TextView) child.findViewById(R.id.tubeStatus); text.setText(message); } } } else { int statusCode = response.code(); // handle request errors ResponseBody errorBody = response.errorBody(); Toast.makeText(getApplicationContext(), "Error code " + errorBody.toString() + " " + statusCode, Toast.LENGTH_SHORT).show(); } }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * On click image view to start stop recording * /* ww w.j ava 2s . c o m*/ * Records time SYNCHRONOUSLY * * @param v */ public void onClickSwitchAction(View v) { Drawable drwStart = getResources().getDrawable(R.drawable.play); Drawable drwStop = getResources().getDrawable(R.drawable.stop); LinearLayout lllFrag = (LinearLayout) v.getParent(); LinearLayout llTimePicker = (LinearLayout) lllFrag.findViewById(R.id.llTimePicker); LinearLayout llStatus = (LinearLayout) lllFrag.findViewById(R.id.llStatus); TextView tvRecording = (TextView) llStatus.findViewById(R.id.tvRecording); ImageView ivRecording = (ImageView) llStatus.findViewById(R.id.ivRecording); Animation anim = new AlphaAnimation(0.0f, 1.0f); Log.d(CLASSNAME, "BEFORE: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); ImageView iv = (ImageView) v; int currentStatus = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).getStatus(); if (currentStatus == ActivitySession.STATUS_STOPPED) { Log.d(CLASSNAME, "Status is STOPPED. Shift to STARTED"); iv.setImageDrawable(drwStop); llTimePicker.setVisibility(View.INVISIBLE); anim.setDuration(500); anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckIn(); } else { Log.d(CLASSNAME, "Status is STARTED. Shift to STOPPED"); iv.setImageDrawable(drwStart); llTimePicker.setVisibility(View.VISIBLE); anim.setRepeatCount(0); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckOut = new Date().getTime(); long lCheckIn = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckOut(); // Save data into both databases DateUtils du = new DateUtils(); Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional // Save in backend recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_SYNCHRONOUS); // Save in local database recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT).show(); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); // ImageView ivParent = (ImageView) liContent.findViewById(R.id.imageViewStart); // ivParent.setImageResource(R.drawable.rec_50x); //TextView tvTimeStamp = (TextView) liContent.getChildAt(1); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); } tvRecording.startAnimation(anim); ivRecording.startAnimation(anim); Log.d(CLASSNAME, "AFTER: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); }
From source file:org.ale.scanner.zotero.EditItemActivity.java
private void extractValues() throws JSONException { JSONObject info = mWorkingItem.getSelectedInfo(); LinearLayout container = ((LinearLayout) findViewById(R.id.editContainer)); LinearLayout row;/*from www . ja v a2 s .co m*/ LinearLayout crow; for (int i = 0; i < container.getChildCount(); i++) { row = (LinearLayout) container.getChildAt(i); switch (row.getId()) { case R.id.edit_field: TextView tv = (TextView) row.findViewById(R.id.label); EditText et = (EditText) row.findViewById(R.id.content); String label = (String) tv.getTag(); String content = et.getText().toString(); info.put(label, content); break; case R.id.edit_creators: JSONArray creators = new JSONArray(); JSONObject creator; for (int c = 0; c < row.getChildCount(); c++) { crow = (LinearLayout) row.getChildAt(c); EditText name = (EditText) crow.findViewById(R.id.creator); if (TextUtils.isEmpty(name.getText().toString())) { continue; } Spinner sp = (Spinner) crow.findViewById(R.id.creator_type); creator = new JSONObject(); int indx = CreatorType.LocalizedBook.indexOf((String) sp.getSelectedItem()); creator.put(CreatorType.type, CreatorType.Book.get(indx)); creator.put(ItemField.Creator.name, name.getText().toString()); creators.put(creator); } info.put(ItemField.creators, creators); break; case R.id.edit_notes: JSONArray notes = new JSONArray(); JSONObject note; EditText note_et; for (int c = 0; c < row.getChildCount(); c++) { crow = (LinearLayout) row.getChildAt(c); note_et = (EditText) crow.findViewById(R.id.content); String note_content = note_et.getText().toString(); if (TextUtils.isEmpty(note_content)) continue; note = new JSONObject(); note.put(ItemField.Note.itemType, ItemField.Note.note); note.put(ItemField.Note.note, note_content); notes.put(note); } info.put(ItemField.notes, notes); break; case R.id.edit_tags: JSONArray tags = new JSONArray(); JSONObject tag; EditText tag_et; for (int c = 0; c < row.getChildCount(); c++) { crow = (LinearLayout) row.getChildAt(c); tag_et = (EditText) crow.findViewById(R.id.content); String tag_content = tag_et.getText().toString(); if (TextUtils.isEmpty(tag_content)) continue; tag = new JSONObject(); tag.put(ItemField.Tag.tag, tag_content); tags.put(tag); } info.put(ItemField.tags, tags); break; default: break; } } }