List of usage examples for android.widget RelativeLayout findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.owncloud.android.ui.activity.FileActivity.java
protected void initDrawer() { // constant settings for action bar when navigation drawer is inited getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // Notification Drawer RelativeLayout navigationDrawerLayout = (RelativeLayout) findViewById(R.id.left_drawer); mDrawerList = (ListView) navigationDrawerLayout.findViewById(R.id.drawer_list); // TODO re-enable when "Accounts" is available in Navigation Drawer // // load Account in the Drawer Title // // User-Icon // ImageView userIcon = (ImageView) navigationDrawerLayout.findViewById(R.id.drawer_userIcon); // userIcon.setImageResource(DisplayUtils.getSeasonalIconId()); ///*from w w w . ja v a 2 s .co m*/ // // Username // TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username); // Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()); // // if (account != null) { // int lastAtPos = account.name.lastIndexOf("@"); // username.setText(account.name.substring(0, lastAtPos)); // } // Display username in drawer Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()); if (account != null) { TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username); int lastAtPos = account.name.lastIndexOf("@"); username.setText(account.name.substring(0, lastAtPos)); } // load slide menu items mDrawerTitles = getResources().getStringArray(R.array.drawer_items); // nav drawer content description from resources mDrawerContentDescriptions = getResources().getStringArray(R.array.drawer_content_descriptions); // nav drawer items mDrawerItems = new ArrayList<NavigationDrawerItem>(); // adding nav drawer items to array // TODO re-enable when "Accounts" is available in Navigation Drawer // Accounts // mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], // mDrawerContentDescriptions[0])); // All Files mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], mDrawerContentDescriptions[0], R.drawable.ic_folder_open)); // TODO Enable when "On Device" is recovered // On Device //mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2], // mDrawerContentDescriptions[2])); // Settings mDrawerItems.add( new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1], R.drawable.ic_settings)); // Logs if (BuildConfig.DEBUG) { mDrawerItems.add( new NavigationDrawerItem(mDrawerTitles[2], mDrawerContentDescriptions[2], R.drawable.ic_log)); } // setting the nav drawer list adapter mNavigationDrawerAdapter = new NavigationDrawerListAdapter(getApplicationContext(), this, mDrawerItems); mDrawerList.setAdapter(mNavigationDrawerAdapter); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); updateActionBarTitleAndHomeButton(null); invalidateOptionsMenu(); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getSupportActionBar().setTitle(R.string.app_name); mDrawerToggle.setDrawerIndicatorEnabled(true); invalidateOptionsMenu(); } }; // Set the list's click listener mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerToggle.setDrawerIndicatorEnabled(false); }
From source file:com.luseen.spacenavigation.SpaceNavigationView.java
/** * Adding given space items to content//from w ww. j av a2 s . c o m * * @param leftContent to left content * @param rightContent and right content */ private void addSpaceItems(LinearLayout leftContent, LinearLayout rightContent) { /** * Removing all views for not being duplicated */ if (leftContent.getChildCount() > 0 || rightContent.getChildCount() > 0) { leftContent.removeAllViews(); rightContent.removeAllViews(); } /** * Clear spaceItemList and badgeList for not being duplicated */ spaceItemList.clear(); badgeList.clear(); /** * Getting LayoutInflater to inflate space item view from XML */ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < spaceItems.size(); i++) { final int index = i; int targetWidth; if (spaceItems.size() > 2) targetWidth = contentWidth / 2; else targetWidth = contentWidth; RelativeLayout.LayoutParams textAndIconContainerParams = new RelativeLayout.LayoutParams(targetWidth, mainContentHeight); RelativeLayout textAndIconContainer = (RelativeLayout) inflater.inflate(R.layout.space_item_view, this, false); textAndIconContainer.setLayoutParams(textAndIconContainerParams); ImageView spaceItemIcon = (ImageView) textAndIconContainer.findViewById(R.id.space_icon); TextView spaceItemText = (TextView) textAndIconContainer.findViewById(R.id.space_text); RelativeLayout badgeContainer = (RelativeLayout) textAndIconContainer .findViewById(R.id.badge_container); spaceItemIcon.setImageResource(spaceItems.get(i).getItemIcon()); spaceItemText.setText(spaceItems.get(i).getItemName()); spaceItemText.setTextSize(TypedValue.COMPLEX_UNIT_PX, spaceItemTextSize); /** * Set custom font to space item textView */ if (isCustomFont) spaceItemText.setTypeface(customFont); /** * Hide item icon and show only text */ if (textOnly) Utils.changeViewVisibilityGone(spaceItemIcon); /** * Hide item text and change icon size */ ViewGroup.LayoutParams iconParams = spaceItemIcon.getLayoutParams(); if (iconOnly) { iconParams.height = spaceItemIconOnlySize; iconParams.width = spaceItemIconOnlySize; spaceItemIcon.setLayoutParams(iconParams); Utils.changeViewVisibilityGone(spaceItemText); } else { iconParams.height = spaceItemIconSize; iconParams.width = spaceItemIconSize; spaceItemIcon.setLayoutParams(iconParams); } /** * Adding space items to item list for future */ spaceItemList.add(textAndIconContainer); /** * Adding badge items to badge list for future */ badgeList.add(badgeContainer); /** * Adding sub views to left and right sides */ if (spaceItems.size() == 2 && leftContent.getChildCount() == 1) { rightContent.addView(textAndIconContainer, textAndIconContainerParams); } else if (spaceItems.size() > 2 && leftContent.getChildCount() == 2) { rightContent.addView(textAndIconContainer, textAndIconContainerParams); } else { leftContent.addView(textAndIconContainer, textAndIconContainerParams); } /** * Changing current selected item tint */ if (i == currentSelectedItem) { spaceItemText.setTextColor(activeSpaceItemColor); Utils.changeImageViewTint(spaceItemIcon, activeSpaceItemColor); } else { spaceItemText.setTextColor(inActiveSpaceItemColor); Utils.changeImageViewTint(spaceItemIcon, inActiveSpaceItemColor); } textAndIconContainer.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { updateSpaceItems(index); } }); } /** * Restore available badges from saveInstance */ restoreBadges(); }
From source file:com.mci.firstidol.activity.MainActivity.java
/** * tabitem/*ww w . j a va2s. c o m*/ * * @param drawable_res * ? * @param string_res * ? * @return */ public RelativeLayout initTabItem(int drawable_res, int string_res) { RelativeLayout layout = null; try { layout = (RelativeLayout) getLayoutInflater().inflate(R.layout.tab_item, null); ImageView index_icon = (ImageView) layout.findViewById(R.id.item_icon); TextView index_name = (TextView) layout.findViewById(R.id.item_name); index_name.setText(context.getResources().getString(string_res)); index_icon.setBackgroundResource(drawable_res); } catch (Exception e) { e.printStackTrace(); } return layout; }
From source file:com.cerema.cloud2.ui.activity.FileActivity.java
/** * sets the given account name in the drawer in case the drawer is available. The account name * is shortened beginning from the @-sign in the username. * * @param navigationDrawerLayout the drawer layout to be used * @param account the account to be set in the drawer */// w ww.j a v a 2 s . c om protected void setUsernameInDrawer(RelativeLayout navigationDrawerLayout, Account account) { if (navigationDrawerLayout != null && account != null) { TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username); int lastAtPos = account.name.lastIndexOf("@"); username.setText(account.name.substring(0, lastAtPos)); } }
From source file:com.cerema.cloud2.ui.activity.FileActivity.java
protected void initDrawer() { // constant settings for action bar when navigation drawer is inited getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // Notification Drawer RelativeLayout navigationDrawerLayout = (RelativeLayout) findViewById(R.id.left_drawer); mDrawerList = (ListView) navigationDrawerLayout.findViewById(R.id.drawer_list); // TODO re-enable when "Accounts" is available in Navigation Drawer // // load Account in the Drawer Title // // User-Icon // ImageView userIcon = (ImageView) navigationDrawerLayout.findViewById(R.id.drawer_userIcon); // userIcon.setImageResource(DisplayUtils.getSeasonalIconId()); ///*from w ww. j a v a 2 s . com*/ // // Username // TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username); // Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()); // // if (account != null) { // int lastAtPos = account.name.lastIndexOf("@"); // username.setText(account.name.substring(0, lastAtPos)); // } // Display username in drawer setUsernameInDrawer(navigationDrawerLayout, AccountUtils.getCurrentOwnCloudAccount(getApplicationContext())); // load slide menu items mDrawerTitles = getResources().getStringArray(R.array.drawer_items); // nav drawer content description from resources mDrawerContentDescriptions = getResources().getStringArray(R.array.drawer_content_descriptions); // nav drawer items mDrawerItems = new ArrayList<NavigationDrawerItem>(); // adding nav drawer items to array // TODO re-enable when "Accounts" is available in Navigation Drawer // Accounts // mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], // mDrawerContentDescriptions[0])); // All Files mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], mDrawerContentDescriptions[0], R.drawable.ic_folder_open)); // TODO Enable when "On Device" is recovered // On Device //mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2], // mDrawerContentDescriptions[2])); // Settings mDrawerItems.add( new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1], R.drawable.ic_settings)); // Logs if (BuildConfig.DEBUG) { mDrawerItems.add( new NavigationDrawerItem(mDrawerTitles[2], mDrawerContentDescriptions[2], R.drawable.ic_log)); } // setting the nav drawer list adapter mNavigationDrawerAdapter = new NavigationDrawerListAdapter(getApplicationContext(), this, mDrawerItems); mDrawerList.setAdapter(mNavigationDrawerAdapter); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); updateActionBarTitleAndHomeButton(null); invalidateOptionsMenu(); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getSupportActionBar().setTitle(R.string.app_name); mDrawerToggle.setDrawerIndicatorEnabled(true); invalidateOptionsMenu(); } }; // Set the list's click listener mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerToggle.setDrawerIndicatorEnabled(false); }
From source file:com.nadmm.airports.afd.AirportDetailsFragment.java
protected void addRunwayRow(LinearLayout layout, Cursor c) { String siteNumber = c.getString(c.getColumnIndex(Runways.SITE_NUMBER)); String runwayId = c.getString(c.getColumnIndex(Runways.RUNWAY_ID)); int length = c.getInt(c.getColumnIndex(Runways.RUNWAY_LENGTH)); int width = c.getInt(c.getColumnIndex(Runways.RUNWAY_WIDTH)); String surfaceType = c.getString(c.getColumnIndex(Runways.SURFACE_TYPE)); String baseId = c.getString(c.getColumnIndex(Runways.BASE_END_ID)); String reciprocalId = c.getString(c.getColumnIndex(Runways.RECIPROCAL_END_ID)); String baseRP = c.getString(c.getColumnIndex(Runways.BASE_END_RIGHT_TRAFFIC)); String reciprocalRP = c.getString(c.getColumnIndex(Runways.RECIPROCAL_END_RIGHT_TRAFFIC)); String rp = null;/*from w w w .j ava2s . co m*/ if (baseRP.equals("Y") && reciprocalRP.equals("Y")) { rp = " (RP)"; } else if (baseRP.equals("Y")) { rp = " (RP " + baseId + ")"; } else if (reciprocalRP.equals("Y")) { rp = " (RP " + reciprocalId + ")"; } int heading = c.getInt(c.getColumnIndex(Runways.BASE_END_HEADING)); if (heading > 0) { heading = (int) GeoUtils.applyDeclination(heading, mDeclination); } else { // Actual heading is not available, try to deduce it from runway id heading = DataUtils.getRunwayHeading(runwayId); } RelativeLayout row = (RelativeLayout) inflate(R.layout.runway_detail_item); TextView tv = (TextView) row.findViewById(R.id.runway_id); tv.setText(runwayId); UiUtils.setRunwayDrawable(getActivity(), tv, runwayId, length, heading); if (rp != null) { tv = (TextView) row.findViewById(R.id.runway_rp); tv.setText(rp); tv.setVisibility(View.VISIBLE); } tv = (TextView) row.findViewById(R.id.runway_size); tv.setText( String.format(Locale.US, "%s x %s", FormatUtils.formatFeet(length), FormatUtils.formatFeet(width))); tv = (TextView) row.findViewById(R.id.runway_surface); tv.setText(DataUtils.decodeSurfaceType(surfaceType)); if (!runwayId.startsWith("H")) { // Save the textview and runway info for later use tv = (TextView) row.findViewById(R.id.runway_wind_info); Bundle tag = new Bundle(); tag.putString(Runways.BASE_END_ID, baseId); tag.putString(Runways.RECIPROCAL_END_ID, reciprocalId); tag.putInt(Runways.BASE_END_HEADING, heading); tv.setTag(tag); mRunwayViews.add(tv); } Bundle args = new Bundle(); args.putString(Runways.SITE_NUMBER, siteNumber); args.putString(Runways.RUNWAY_ID, runwayId); addClickableRow(layout, row, RunwaysFragment.class, args); }
From source file:com.sonymobile.android.media.testmediaplayer.MainActivity.java
public void init() { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(getApplicationContext()); mMediaPlayer.setScreenOnWhilePlaying(true); }//from w ww . j a v a2s . c om mHandler = new Handler(); mDecorView = getWindow().getDecorView(); mSeekbar = (SeekBar) findViewById(R.id.activity_main_seekbar); mSeekbar.setMax(1000); mPlayPauseButton = (ImageView) findViewById(R.id.activity_main_playpause_button); mSeekBarUpdater = new SeekbarUpdater(mSeekbar, mMediaPlayer); mTopLayout = (RelativeLayout) findViewById(R.id.activity_main_mainlayout); mTrackDialog = new AudioSubtitleTrackDialog(this); mAudioPos = mSubPos = 0; mTimeView = (TextView) findViewById(R.id.activity_main_time); mDurationView = (TextView) findViewById(R.id.activity_main_duration); mTimeLayout = (LinearLayout) findViewById(R.id.activity_main_timelayout); mTimeTracker = new TimeTracker(mMediaPlayer, mTimeView); mSubtitleView = (TextView) findViewById(R.id.activity_main_subtitleView); mSubtitleRenderer = new SubtitleRenderer(mSubtitleView, Looper.myLooper(), mMediaPlayer); mSubtitleLayoutAboveTimeView = (RelativeLayout.LayoutParams) mSubtitleView.getLayoutParams(); mSubtitleLayoutBottom = (RelativeLayout.LayoutParams) ((TextView) findViewById( R.id.activity_main_subtitleView_params)).getLayoutParams(); mTimeSeekView = (TextView) findViewById(R.id.activity_main_time_seek); mMediaPlayer.setOnInfoListener(this); RelativeLayout browsingL = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout); ExpandableListView elv = (ExpandableListView) browsingL.findViewById(R.id.file_browsing_exp_list_view); ListView lv = (ListView) browsingL.findViewById(R.id.file_browsing_listview); RelativeLayout debugLayout = (RelativeLayout) findViewById(R.id.activity_main_debug_view); LinearLayout debugLinearLayout = (LinearLayout) debugLayout.findViewById(R.id.activity_main_debug_linear); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setScrimColor(Color.TRANSPARENT); mDrawerLayout.setDrawerListener(this); mFileBrowser = new MediaBrowser(this, elv, lv, mMediaPlayer, (MainActivity) this, mDrawerLayout, debugLinearLayout); mIsFileBrowsing = false; mPreview = (SurfaceView) findViewById(R.id.mSurfaceView); mPreview.setOnTouchListener(this); mTopLayout.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); mPreview.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); mSubtitleTracker = new HashMap<Integer, Integer>(); mAudioTracker = new HashMap<Integer, Integer>(); findViewById(R.id.activity_main_loading_panel).bringToFront(); findViewById(R.id.activity_main_browsing_layout).bringToFront(); mUpperControls = (RelativeLayout) findViewById(R.id.UpperButtonLayout); mBottomControls = (RelativeLayout) findViewById(R.id.ButtonLayout); mSlideInAnimation = AnimationUtils.loadAnimation(this, R.anim.in_top); mSlideInAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mUpperControls.setVisibility(View.VISIBLE); Runnable r = new Runnable() { @Override public void run() { mBottomControls.setVisibility(View.INVISIBLE); } }; mHandler.postDelayed(r, 3500); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mBottomControls.setVisibility(View.INVISIBLE); } }); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mFadeOutRunnable = new Runnable() { @Override public void run() { mSeekbar.setEnabled(false); Animation fadeoutBottom = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out_bottom); fadeoutBottom.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mOngoingAnimation) { mOngoingAnimation = false; mBottomControls.setVisibility(View.INVISIBLE); mUpperControls.setVisibility(View.INVISIBLE); mSeekbar.setVisibility(View.GONE); mTimeLayout.setVisibility(View.GONE); mSubtitleView.setLayoutParams(mSubtitleLayoutBottom); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mOngoingAnimation = true; } }); Animation fadeoutTop = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out_top); mBottomControls.startAnimation(fadeoutBottom); mUpperControls.startAnimation(fadeoutTop); mSeekbar.startAnimation(fadeoutBottom); mTimeLayout.startAnimation(fadeoutBottom); } }; mHideNavigationRunnable = new Runnable() { @Override public void run() { mPreview.setSystemUiVisibility(mUiOptions); } }; mDecorView.setOnSystemUiVisibilityChangeListener(this); mSeekbar.setOnSeekBarChangeListener(new OwnOnSeekBarChangeListener(mMediaPlayer)); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnSeekCompleteListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnSubtitleDataListener(this); RelativeLayout browsingLayout = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout); DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) browsingLayout.getLayoutParams(); Resources resources = getResources(); int top = 0; int bottom = 0; RelativeLayout.LayoutParams tempParams; int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { top = resources.getDimensionPixelSize(resourceId); } resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { bottom = resources.getDimensionPixelSize(resourceId); } if (navigationBarAtBottom()) { tempParams = (RelativeLayout.LayoutParams) mBottomControls.getLayoutParams(); tempParams.bottomMargin += bottom; mBottomControls.setLayoutParams(tempParams); tempParams = (RelativeLayout.LayoutParams) mSeekbar.getLayoutParams(); tempParams.bottomMargin += bottom; mSeekbar.setLayoutParams(tempParams); params.setMargins(0, top, 0, bottom); } else { tempParams = (RelativeLayout.LayoutParams) mBottomControls.getLayoutParams(); tempParams.rightMargin += bottom; mBottomControls.setLayoutParams(tempParams); params.setMargins(0, top, 0, 0); } browsingLayout.setLayoutParams(params); mDrawerLayout.openDrawer(Gravity.START); mMediaPlayer.setOnOutputControlListener(this); }
From source file:com.tencent.wstt.gt.activity.GTLogFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View logLayout = inflater.inflate(R.layout.gt_logactivity, container, false); displayWidth = DeviceUtils.getDisplayWidth(getActivity()); rl_log_filter = (RelativeLayout) logLayout.findViewById(R.id.rl_log_filter); cb_logcatSwitch = (GTCheckBox) logLayout.findViewById(R.id.cb_logcat_switch); cb_logcatSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override//from w ww .j a v a 2 s. co m public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // TODO logcat? logcatTask = new LogcatRunnable(); new Thread(logcatTask).start(); } else { logcatTask.killReader(); } } }); btn_delete = (ImageButton) logLayout.findViewById(R.id.gtlog_delete); btn_save = (ImageButton) logLayout.findViewById(R.id.gtlog_save); btn_open = (ImageButton) logLayout.findViewById(R.id.gtlog_open); btn_level_toast = (ImageButton) logLayout.findViewById(R.id.log_level_toast); btn_tag_toast = (ImageButton) logLayout.findViewById(R.id.log_tag_toast); /* * ??ImageView ??filterListViewfilterListView */ img_empty = (ImageView) logLayout.findViewById(R.id.view_empty); img_empty.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { img_empty.setVisibility(View.GONE); filterListView.setVisibility(View.GONE); cancelFilterMsgInput(v); return false; } }); /* * ? */ RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.gt_dailog_save, null, false); ImageButton btn_cleanSavePath = (ImageButton) rl_save.findViewById(R.id.save_clean); btn_cleanSavePath.setOnClickListener(this); et_savePath = (EditText) rl_save.findViewById(R.id.save_editor); String lastSaveLog = GTLogInternal.getLastSaveLog(); if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.LOG_POSFIX)) { lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf(".")); } et_savePath.setText(lastSaveLog); dlg_save = new Builder(getActivity()).setTitle(getString(R.string.save_file)).setView(rl_save) .setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // ?? String path = et_savePath.getText().toString(); try { File f = null; if (FileUtil.isPathStringValid(path)) { String validPath = FileUtil.convertValidFilePath(path, LogUtils.LOG_POSFIX); if (FileUtil.isPath(validPath)) { f = new File(validPath); f.mkdirs(); } else { f = new File(Env.ROOT_LOG_FOLDER, validPath); } GTLogInternal.setLastSaveLog(validPath); } if (f.exists()) { f.delete(); } LogUtils.writeLog(logAdapter.getUIEntryList(), f, false); } catch (Exception e) { e.printStackTrace(); } dialog.dismiss(); } }).create(); btn_save.setOnClickListener(this); // btn_delete.setOnClickListener(this); // btn_open.setOnClickListener(this); // rl_loglist = (RelativeLayout) logLayout.findViewById(R.id.rl_loglist); listView = (ListView) logLayout.findViewById(R.id.loglist); initCurLogAdapter(); logAdapter.setFilter(); listView.setAdapter(logAdapter); // button??? listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { rl_log_filter.setVisibility(View.GONE); } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (visibleItemCount + firstVisibleItem == totalItemCount) { logAdapter.setAutoRefresh(true); } else { logAdapter.setAutoRefresh(false); } } }); // button? rl_loglist.setOnClickListener(this); listView.setOnTouchListener(logListTouchListener); // ? filterListView = (ListView) logLayout.findViewById(R.id.spinner_list); tagAdapter = new ArrayAdapter<String>(getActivity(), R.layout.gt_simple_dropdown_item); filterListView.setAdapter(tagAdapter); filterListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long arg3) { img_empty.setVisibility(View.GONE); filterListView.setVisibility(View.GONE); if (parent.getAdapter() == tagAdapter) { if (position == 0) GTLogInternal.setCurFilterTag(""); else GTLogInternal.setCurFilterTag((String) parent.getAdapter().getItem(position)); btn_tag.setText(tagAdapter.getItem(position)); } else if (parent.getAdapter() instanceof MsgAdaptor) { String sCurSelectedMsg = (String) parent.getAdapter().getItem(position); LinkedList<String> curShowDownMsgList = GTLogInternal.getCurFilterShowDownMsgList(); LinkedList<String> msgHistory = GTLogInternal.getCurFilterMsgHistory(); GTLogInternal.setCurFilterMsg(sCurSelectedMsg); msgWatched = false; et_Msg.removeTextChangedListener(msg_watcher); String s = curShowDownMsgList.remove(position); curShowDownMsgList.addFirst(s); msgHistory.remove(s); msgHistory.addFirst(s); et_Msg.setText(sCurSelectedMsg); btn_msg_clear.setVisibility(View.VISIBLE); cancelFilterMsgInput(parent); } else { GTLogInternal.setCurFilterLevel(position); btn_level.setText(levelAdapter.getItem(position)); } onLogChanged(); } }); // Activity??? GTLogInternal.addLogListener(this); // ? //btn_search = (ImageButton) findViewById(R.id.log_search); btn_search = (ImageButton) logLayout.findViewById(R.id.gtlog_search); btn_search.setOnClickListener(this); // btn_level = (Button) logLayout.findViewById(R.id.log_level); levelAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.log_level, R.layout.gt_simple_dropdown_item); btn_level.setText(levelAdapter.getItem(GTLogInternal.getCurFilterLevel())); btn_level.setOnClickListener(this); // TAG btn_tag = (Button) logLayout.findViewById(R.id.log_tag); if (GTLogInternal.getCurFilterTag().length() == 0) { btn_tag.setText("TAG"); } else { btn_tag.setText(GTLogInternal.getCurFilterTag()); } btn_tag.setOnClickListener(this); // et_Msg = (EditText) logLayout.findViewById(R.id.log_msg); et_Msg.setText(GTLogInternal.getCurFilterMsg()); et_Msg.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus && !logAdapter.isEmpty())// edit? { msgEtOnFocusOrClick(); } } }); et_Msg.setOnClickListener(this); et_Msg.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: // ?showdown? msgWatched = false; et_Msg.removeTextChangedListener(msg_watcher); String word = et_Msg.getText().toString(); if (!word.equals("")) { LinkedList<String> curShowDownMsgList = GTLogInternal.getCurFilterShowDownMsgList(); LinkedList<String> msgHistory = GTLogInternal.getCurFilterMsgHistory(); msgHistory.remove(word); msgHistory.addFirst(word); curShowDownMsgList.remove(word); curShowDownMsgList.addFirst(word); } filterListView.setVisibility(View.GONE); img_empty.setVisibility(View.GONE); cancelFilterMsgInput(v); return true; } return false; } }); // ? btn_msg_clear = (ImageButton) logLayout.findViewById(R.id.log_msg_clear); btn_msg_clear.setOnClickListener(this); if (et_Msg.getText().toString().length() > 0) { btn_msg_clear.setVisibility(View.VISIBLE); } else { btn_msg_clear.setVisibility(View.GONE); } // ? btn_msg_input_cancel = (Button) logLayout.findViewById(R.id.log_msg_cancel); btn_msg_input_cancel.setOnClickListener(this); handler = new Handler(); return logLayout; }
From source file:it.sasabz.android.sasabus.fragments.OnlineSearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this.inflater_glob = inflater; result = inflater.inflate(R.layout.online_search_layout, container, false); Date datum = new Date(); SimpleDateFormat simple = new SimpleDateFormat("dd.MM.yyyy HH:mm"); TextView datetime = (TextView) result.findViewById(R.id.time); String datetimestring = ""; datetimestring = simple.format(datum); datetime.setText(datetimestring);// ww w. jav a 2 s.c o m Button search = (Button) result.findViewById(R.id.search); search.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AutoCompleteTextView from = (AutoCompleteTextView) result.findViewById(R.id.from_text); AutoCompleteTextView to = (AutoCompleteTextView) result.findViewById(R.id.to_text); TextView datetime = (TextView) result.findViewById(R.id.time); String from_txt = getThis().getResources().getString(R.string.from_txt); if ((!from.getText().toString().trim().equals("") || !from.getHint().toString().trim().equals(from_txt)) && !to.getText().toString().trim().equals("")) { //Intent getSelect = new Intent(getThis().getActivity(), OnlineSelectStopActivity.class); String fromtext = ""; if (from.getText().toString().trim().equals("")) fromtext = from.getHint().toString(); else fromtext = from.getText().toString(); String totext = to.getText().toString(); fromtext = "(" + fromtext.replace(" -", ")"); totext = "(" + totext.replace(" -", ")"); Fragment fragment = new OnlineSelectFragment(fromtext, totext, datetime.getText().toString()); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); Fragment old = fragmentManager.findFragmentById(R.id.onlinefragment); if (old != null) { ft.remove(old); } ft.add(R.id.onlinefragment, fragment); ft.addToBackStack(null); ft.commit(); fragmentManager.executePendingTransactions(); } } }); datetime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getThis().getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob .inflate(R.layout.date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); TextView dt = (TextView) result.findViewById(R.id.time); String datetimestring = dt.getText().toString(); SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date datetime = null; try { datetime = datetimeformat.parse(datetimestring); } catch (Exception e) { ; } mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes()); mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate()); // Check is system is set to use 24h time (this doesn't seem to // work as expected though) final String timeS = android.provider.Settings.System.getString( getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); String datetimestring = ""; int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH); int month = mDateTimePicker.get(Calendar.MONTH) + 1; int year = mDateTimePicker.get(Calendar.YEAR); int hour = 0; int min = 0; int append = 0; if (mDateTimePicker.is24HourView()) { hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY); min = mDateTimePicker.get(Calendar.MINUTE); } else { hour = mDateTimePicker.get(Calendar.HOUR); min = mDateTimePicker.get(Calendar.MINUTE); if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) { append = 1; } else { append = 2; } } if (day < 10) { datetimestring += "0"; } datetimestring += (day + "."); if (month < 10) { datetimestring += "0"; } datetimestring += (month + "." + year + " "); if (hour < 10) { datetimestring += "0"; } datetimestring += (hour + ":"); if (min < 10) { datetimestring += "0"; } datetimestring += min; switch (append) { case 1: datetimestring += " AM"; break; case 2: datetimestring += " PM"; break; } TextView time = (TextView) result.findViewById(R.id.time); time.setText(datetimestring); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is // clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); ImageButton datepicker = (ImageButton) result.findViewById(R.id.datepicker); datepicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getThis().getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob .inflate(R.layout.date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); TextView dt = (TextView) result.findViewById(R.id.time); String datetimestring = dt.getText().toString(); SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date datetime = null; try { datetime = datetimeformat.parse(datetimestring); } catch (Exception e) { ; } mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes()); mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate()); // Check is system is set to use 24h time (this doesn't seem to // work as expected though) final String timeS = android.provider.Settings.System.getString( getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); // Update demo TextViews when the "OK" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); String datetimestring = ""; int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH); int month = mDateTimePicker.get(Calendar.MONTH) + 1; int year = mDateTimePicker.get(Calendar.YEAR); int hour = 0; int min = 0; int append = 0; if (mDateTimePicker.is24HourView()) { hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY); min = mDateTimePicker.get(Calendar.MINUTE); } else { hour = mDateTimePicker.get(Calendar.HOUR); min = mDateTimePicker.get(Calendar.MINUTE); if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) { append = 1; } else { append = 2; } } if (day < 10) { datetimestring += "0"; } datetimestring += (day + "."); if (month < 10) { datetimestring += "0"; } datetimestring += (month + "." + year + " "); if (hour < 10) { datetimestring += "0"; } datetimestring += (hour + ":"); if (min < 10) { datetimestring += "0"; } datetimestring += min; switch (append) { case 1: datetimestring += " AM"; break; case 2: datetimestring += " PM"; break; } TextView time = (TextView) result.findViewById(R.id.time); time.setText(datetimestring); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is // clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); from = (AutoCompleteTextView) result.findViewById(R.id.from_text); to = (AutoCompleteTextView) result.findViewById(R.id.to_text); from.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(from.getWindowToken(), 0); } }); to.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(to.getWindowToken(), 0); } }); LocationManager locman = (LocationManager) this.getActivity().getSystemService(Context.LOCATION_SERVICE); Location lastloc = locman.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (MySQLiteDBAdapter.exists(this.getActivity())) { if (lastloc == null) { lastloc = locman.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } if (lastloc != null) { try { Palina palina = PalinaList.getPalinaGPS(lastloc); if (palina != null) { from.setHint(palina.toString()); } } catch (Exception e) { Log.e("HomeActivity", "Fehler bei der Location", e); } } else { Log.v("HomeActivity", "No location found!!"); } Vector<DBObject> palinalist = PalinaList.getNameList(); MyAutocompleteAdapter adapterfrom = new MyAutocompleteAdapter(this.getActivity(), android.R.layout.simple_list_item_1, palinalist); MyAutocompleteAdapter adapterto = new MyAutocompleteAdapter(this.getActivity(), android.R.layout.simple_list_item_1, palinalist); from.setAdapter(adapterfrom); to.setAdapter(adapterto); InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(from.getWindowToken(), 0); mgr.hideSoftInputFromWindow(to.getWindowToken(), 0); } Button favorites = (Button) result.findViewById(R.id.favorites); favorites.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SelectFavoritenDialog dialog = new SelectFavoritenDialog(getThis()); dialog.show(); } }); Button mappicker = (Button) result.findViewById(R.id.map); mappicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MapSelectActivity.class); startActivityForResult(intent, REQUESTCODE_ACTIVITY); } }); return result; }
From source file:org.connectbot.ConsoleFragment.java
/** * Adds a new TerminalBridge to the current set of views in our ViewFlipper. * * @param bridge TerminalBridge to add to our ViewFlipper * @return the child index of the new view in the ViewFlipper *//*from w w w . j av a2s. c o m*/ private int addNewTerminalView(TerminalBridge bridge) { // let them know about our prompt handler services bridge.promptHelper.setHandler(promptHandler); // inflate each terminal view RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.item_terminal, flip, false); // set the terminal overlay text TextView overlay = (TextView) view.findViewById(R.id.terminal_overlay); overlay.setText(bridge.host.getNickname()); // and add our terminal view control, using index to place behind overlay TerminalView terminal = new TerminalView(getActivity(), bridge); terminal.setId(R.id.console_flip); view.addView(terminal, 0); synchronized (flip) { // finally attach to the flipper flip.addView(view); flip.setVisibility(View.VISIBLE); return flip.getChildCount() - 1; } }