Example usage for android.widget RelativeLayout findViewById

List of usage examples for android.widget RelativeLayout findViewById

Introduction

In this page you can find the example usage for android.widget RelativeLayout findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java

private void addCmTab(final int position, String title, int resId) {
    RelativeLayout tab = (RelativeLayout) inflate(getContext(), R.layout.cm_pst__tab, null);
    ImageView iv = (ImageView) tab.findViewById(R.id.pst_iv_tab);
    iv.setImageResource(resId);//w ww.  j a  va  2s . co m
    iv.setVisibility(View.VISIBLE);
    TextView tv = (TextView) tab.findViewById(R.id.pst_tv_tab);
    tv.setText(title);
    tv.setGravity(Gravity.CENTER);
    tv.setSingleLine();
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mOnPageClickedLisener) {
                mOnPageClickedLisener.onPageClicked(position);
            }
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);
}

From source file:com.gsma.mobileconnect.helpers.AuthorizationService.java

/**
 * Handles the process between the MNO and the end user for the end user to
 * sign in/ authorize the application. The application hands over to the
 * browser during the authorization step. On completion the MNO redirects to
 * the application sending the completion information as URL parameters.
 *
 * @param config           the mobile config
 * @param authUri          the URI to the MNO's authorization page
 * @param scopes           which is an application specified string value.
 * @param redirectUri      which is the return point after the user has
 *                         authenticated/consented.
 * @param state            which is application specified.
 * @param nonce            which is application specified.
 * @param maxAge           which is an integer value.
 * @param acrValues        which is an application specified.
 * @param context          The Android context
 * @param listener         The listener used to alert the activity to the change
 * @param response         The information captured in the discovery phase.
 * @param hmapExtraOptions A HashMap containing additional authorization options
 * @throws UnsupportedEncodingException/*from   ww w  . j  a  v  a 2s .com*/
 */
public void authorize(final MobileConnectConfig config, String authUri, final String scopes,
        final String redirectUri, final String state, final String nonce, final int maxAge,
        final String acrValues, final Context context, final AuthorizationListener listener,
        final DiscoveryResponse response, final HashMap<String, Object> hmapExtraOptions)
        throws UnsupportedEncodingException {
    final JsonNode discoveryResponseWrapper = response.getResponseData();
    final JsonNode discoveryResponseJsonNode = discoveryResponseWrapper.get("response");

    String clientId = null;
    String clientSecret = null;

    try {
        clientId = AndroidJsonUtils.getExpectedStringValue(discoveryResponseJsonNode, "client_id");
    } catch (final NoFieldException e) {
        e.printStackTrace();
    }
    Log.d(TAG, "clientId = " + clientId);

    try {
        clientSecret = AndroidJsonUtils.getExpectedStringValue(discoveryResponseJsonNode, "client_secret");
    } catch (final NoFieldException e) {
        e.printStackTrace();
    }
    Log.d(TAG, "clientSecret = " + clientSecret);

    try {
        Log.d(TAG, "clientSecret = " + clientId);
        Log.d(TAG, "authUri = " + authUri);
        Log.d(TAG, "responseType = code");
        Log.d(TAG, "clientId = " + clientSecret);
        Log.d(TAG, "scopes = " + scopes);
        Log.d(TAG, "returnUri = " + redirectUri);
        Log.d(TAG, "state = " + state);
        Log.d(TAG, "nonce = " + nonce);
        Log.d(TAG, "maxAge = " + maxAge);
        Log.d(TAG, "acrValues = " + acrValues);

        if (authUri == null) {
            authUri = "";
        }
        String requestUri = authUri;
        if (authUri.indexOf("?") == -1) {
            requestUri += "?";
        } else if (authUri.indexOf("&") == -1) {
            requestUri += "&";
        }
        final String charSet = Charset.defaultCharset().name();
        requestUri += "response_type=" + URLEncoder.encode("code", charSet);
        requestUri += "&client_id=" + URLEncoder.encode(clientId, charSet);
        requestUri += "&scope=" + URLEncoder.encode(scopes, charSet);
        requestUri += "&redirect_uri=" + URLEncoder.encode(redirectUri, charSet);
        requestUri += "&state=" + URLEncoder.encode(state, charSet);
        requestUri += "&nonce=" + URLEncoder.encode(nonce, charSet);
        //  requestUri += "&prompt=" + URLEncoder.encode(prompt.value(), charSet);
        requestUri += "&max_age=" + URLEncoder.encode(Integer.toString(maxAge), charSet);
        requestUri += "&acr_values=" + URLEncoder.encode(acrValues);

        if (hmapExtraOptions != null && hmapExtraOptions.size() > 0) {
            for (final String key : hmapExtraOptions.keySet()) {
                requestUri += "&" + key + "="
                        + URLEncoder.encode(hmapExtraOptions.get(key).toString(), charSet);
            }
        }

        final RelativeLayout webViewLayout = (RelativeLayout) LayoutInflater.from(context)
                .inflate(R.layout.layout_web_view, null);

        final InteractableWebView webView = (InteractableWebView) webViewLayout.findViewById(R.id.web_view);
        final ProgressBar progressBar = (ProgressBar) webViewLayout.findViewById(R.id.progressBar);

        final DiscoveryAuthenticationDialog dialog = new DiscoveryAuthenticationDialog(context);

        if (webView.getParent() != null) {
            ((ViewGroup) webView.getParent()).removeView(webView);
        }

        dialog.setContentView(webView);

        webView.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onCloseWindow(final WebView w) {
                super.onCloseWindow(w);
                Log.d(TAG, "Window close");
                w.setVisibility(View.INVISIBLE);
                w.destroy();
            }
        });

        final AuthorizationWebViewClient client = new AuthorizationWebViewClient(dialog, progressBar, listener,
                redirectUri, config, response);
        webView.setWebViewClient(client);

        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(final DialogInterface dialogInterface) {
                Log.e("Auth Dialog", "dismissed");
                dialogInterface.dismiss();
                closeWebViewAndNotify(listener, webView);
            }
        });

        webView.loadUrl(requestUri);

        try {
            dialog.show();
        } catch (final WindowManager.BadTokenException exception) {
            Log.e("Discovery Dialog", exception.getMessage());
        }
    } catch (final NullPointerException e) {
        Log.d(TAG, "NullPointerException=" + e.getMessage(), e);
    }
}

From source file:com.limewoodmedia.nsdroid.activities.World.java

private void doSearch(final String string) {
    searchResults.removeAllViews();//w  ww .  jav  a2  s  . c o  m
    final LoadingView loadingView = (LoadingView) search.findViewById(R.id.loading);
    LoadingHelper.startLoading(loadingView, R.string.searching, this);
    // Don't update automatically if we're reading back in history
    errorMessage = getResources().getString(R.string.general_error);
    new ParallelTask<Void, Void, Boolean>() {
        protected Boolean doInBackground(Void... params) {
            try {
                try {
                    nData = API.getInstance(World.this).getNationInfo(string, NationData.Shards.NAME,
                            NationData.Shards.CATEGORY, NationData.Shards.REGION);
                } catch (UnknownNationException e) {
                    nData = null;
                }

                try {
                    rData = API.getInstance(World.this).getRegionInfo(string, NAME, NUM_NATIONS, DELEGATE);
                } catch (UnknownRegionException e) {
                    rData = null;
                }

                return true;
            } catch (RateLimitReachedException e) {
                e.printStackTrace();
                errorMessage = getResources().getString(R.string.rate_limit_reached);
            } catch (RuntimeException e) {
                e.printStackTrace();
                errorMessage = e.getMessage();
            } catch (XmlPullParserException e) {
                e.printStackTrace();
                errorMessage = getResources().getString(R.string.xml_parser_exception);
            } catch (IOException e) {
                e.printStackTrace();
                errorMessage = getResources().getString(R.string.api_io_exception);
            }

            return false;
        }

        protected void onPostExecute(Boolean result) {
            LoadingHelper.stopLoading(loadingView);
            if (result) {
                // Show search results
                RelativeLayout nation = (RelativeLayout) getLayoutInflater().inflate(R.layout.search_nation,
                        searchResults, false);
                if (nData != null) {
                    ((TextView) nation.findViewById(R.id.nation_name)).setText(nData.name);
                    ((TextView) nation.findViewById(R.id.nation_category)).setText(nData.category);
                    ((TextView) nation.findViewById(R.id.nation_region)).setText(nData.region);
                    nation.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(World.this, Nation.class);
                            intent.setData(Uri.parse(
                                    "com.limewoodMedia.nsdroid.nation://" + TagParser.nameToId(nData.name)));
                            startActivity(intent);
                        }
                    });
                } else {
                    ((TextView) nation.findViewById(R.id.nation_name)).setText(R.string.no_nation_found);
                    ((TextView) nation.findViewById(R.id.nation_category)).setVisibility(View.GONE);
                    ((TextView) nation.findViewById(R.id.nation_region)).setVisibility(View.GONE);
                }
                searchResults.addView(nation);
                RelativeLayout region = (RelativeLayout) getLayoutInflater().inflate(R.layout.search_region,
                        searchResults, false);
                if (rData != null) {
                    ((TextView) region.findViewById(R.id.region_name)).setText(rData.name);
                    ((TextView) region.findViewById(R.id.region_nations))
                            .setText(Integer.toString(rData.numNations));
                    ((TextView) region.findViewById(R.id.region_wad)).setText(rData.delegate);
                    region.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(World.this, Region.class);
                            intent.setData(Uri.parse(
                                    "com.limewoodMedia.nsdroid.region://" + TagParser.nameToId(rData.name)));
                            startActivity(intent);
                        }
                    });
                } else {
                    ((TextView) region.findViewById(R.id.region_name)).setText(R.string.no_region_found);
                    ((TextView) region.findViewById(R.id.region_nations_label)).setVisibility(View.GONE);
                    ((TextView) region.findViewById(R.id.region_nations)).setVisibility(View.GONE);
                    ((TextView) region.findViewById(R.id.region_wad_label)).setVisibility(View.GONE);
                    ((TextView) region.findViewById(R.id.region_wad)).setVisibility(View.GONE);
                }
                searchResults.addView(region);
            } else {
                Toast.makeText(World.this, errorMessage, Toast.LENGTH_SHORT).show();
            }
            View view = World.this.getCurrentFocus();
            if (view != null) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
            }
        }
    }.execute();
}

From source file:com.mycompany.popularmovies.DetailActivity.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    if (cursorLoader == mGeneralInfoLoader) {
        if (cursor != null && cursor.moveToFirst()) {
            int columnIndexPosterPath = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_POSTER_PATH);
            String posterPath = MovieAdapter.POSTER_BASE_URL_W185 + cursor.getString(columnIndexPosterPath);
            Picasso picasso = Picasso.with(getActivity());
            picasso.load(posterPath).into(mPosterImageView);

            int columnIndexTitle = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_TITLE);
            String title = cursor.getString(columnIndexTitle);
            mTitleTextView.setText(title);

            int columnIndexIsFavorite = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_FAVORITED);
            int isFavorite = cursor.getInt(columnIndexIsFavorite);
            mHeartImageView/*from  ww  w .  j  a va 2  s. com*/
                    .setImageResource(isFavorite == 1 ? R.drawable.heart_active : R.drawable.heart_inactive);
            mHeartImageView.setOnClickListener(this);

            int columnIndexReleaseDate = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_RELEASE_DATE);
            String releaseDateText = cursor.getString(columnIndexReleaseDate);
            String releaseYearText = releaseDateText.substring(0, Math.min(releaseDateText.length(), 4));
            mReleaseYearTextView.setText(releaseYearText);

            int columnIndexVoteAverage = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_VOTE_AVERAGE);
            float vote_average = cursor.getFloat(columnIndexVoteAverage);
            mRatingBar.setRating(vote_average);

            int columnIndexSynopsis = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_SYNOPSIS);
            mSynopsisTextView.setText(cursor.getString(columnIndexSynopsis));

            // If onCreateOptionsMenu has already happened, we need to update the share intent now.
            if (mShareActionProvider != null) {
                mShareText = title;
                mShareActionProvider.setShareIntent(createShareIntent());
            }
        } else {
            Log.e(LOG_TAG, "Cursor to populate general info was empty or null!");
        }
    } else if (cursorLoader == mTrailerLoader) {
        if (cursor == null || !cursor.moveToFirst()) {
            mTrailerListTitle.setVisibility(View.INVISIBLE);
        } else {
            mTrailerListTitle.setVisibility(View.VISIBLE);
            for (cursor.moveToFirst(); cursor.getPosition() < cursor.getCount(); cursor.moveToNext()) {
                int columnIndexName = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_NAME);
                String trailerName = cursor.getString(columnIndexName);

                int columnIndexLanguageCode = cursor
                        .getColumnIndex(MovieContract.TrailersTable.COLUMN_LANGUAGE_CODE);
                String trailerLanguageCode = cursor.getString(columnIndexLanguageCode);

                String trailer_summary = String.format("%s (%s)", trailerName,
                        trailerLanguageCode.toUpperCase());

                int columnIndexSite = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_SITE);
                String site = cursor.getString(columnIndexSite);

                int columnIndexKey = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_KEY);
                String key = cursor.getString(columnIndexKey);

                String link = null;
                if (site.compareTo("YouTube") == 0) {
                    link = "https://www.youtube.com/watch?v=" + key;
                } else {
                    Log.e(LOG_TAG, "Unsupported site: " + site);
                }

                ImageView trailerThumbnail = (ImageView) mActivity.getLayoutInflater()
                        .inflate(R.layout.detail_fragment_trailer_item, null, false);
                if (site.compareTo("YouTube") == 0) {
                    Picasso picasso = Picasso.with(mActivity);
                    String youtubeThumbnailPath = String.format("http://img.youtube.com/vi/%s/mqdefault.jpg",
                            key);
                    picasso.load(youtubeThumbnailPath).into(trailerThumbnail);
                    trailerThumbnail.setTag(link);
                    trailerThumbnail.setOnClickListener(this);
                }

                mTrailerList.addView(trailerThumbnail);
            }
        }
    } else if (cursorLoader == mReviewLoader) {
        if (cursor == null || !cursor.moveToFirst()) {
            mReviewListTitle.setVisibility(View.INVISIBLE);
        } else {
            mReviewListTitle.setVisibility(View.VISIBLE);
            String colors[] = { "#00BFFF", "#00CED1", "#FF8C00", "#00FA9A", "#9400D3" };
            for (cursor.moveToFirst(); cursor.getPosition() < cursor.getCount(); cursor.moveToNext()) {
                int columnIndexAuthor = cursor.getColumnIndex(MovieContract.ReviewsTable.COLUMN_AUTHOR);
                String author = cursor.getString(columnIndexAuthor);
                String authorAbbreviation = author != null && author.length() >= 1 ? author.substring(0, 1)
                        : "?";

                int columnIndexReviewText = cursor
                        .getColumnIndex(MovieContract.ReviewsTable.COLUMN_REVIEW_TEXT);
                String reviewText = cursor.getString(columnIndexReviewText);

                RelativeLayout review = (RelativeLayout) mActivity.getLayoutInflater()
                        .inflate(R.layout.detail_fragment_review_item, null, false);
                review.setOnClickListener(this);
                review.setTag(TAG_REVIEW_COLLAPSED);

                TextView authorIcon = (TextView) review.findViewById(R.id.author_icon);
                authorIcon.setText(authorAbbreviation);
                int color = Color.parseColor(colors[cursor.getPosition() % colors.length]);
                authorIcon.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);

                TextView authorFullName = (TextView) review.findViewById(R.id.author_full_name);
                authorFullName.setText(author);

                TextView reviewTextView = (TextView) review.findViewById(R.id.review_text);
                reviewTextView.setText(reviewText);

                mReviewList.addView(review);
            }
        }
    }
}

From source file:org.mozilla.gecko.AwesomeBar.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.d(LOGTAG, "creating awesomebar");

    mResolver = Tabs.getInstance().getContentResolver();

    setContentView(R.layout.awesomebar);

    if (Build.VERSION.SDK_INT >= 11) {
        RelativeLayout actionBarLayout = (RelativeLayout) GeckoActionBar.getCustomView(this);
        mGoButton = (ImageButton) actionBarLayout.findViewById(R.id.awesomebar_button);
        mText = (AwesomeBarEditText) actionBarLayout.findViewById(R.id.awesomebar_text);
    } else {// w  w  w . j  a v a 2 s  . co m
        mGoButton = (ImageButton) findViewById(R.id.awesomebar_button);
        mText = (AwesomeBarEditText) findViewById(R.id.awesomebar_text);
    }

    TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
    tabWidget.setDividerDrawable(null);

    mAwesomeTabs = (AwesomeBarTabs) findViewById(R.id.awesomebar_tabs);
    mAwesomeTabs.setOnUrlOpenListener(new AwesomeBarTabs.OnUrlOpenListener() {
        public void onUrlOpen(String url) {
            openUrlAndFinish(url);
        }

        public void onSearch(String engine) {
            openSearchAndFinish(mText.getText().toString(), engine);
        }
    });

    mGoButton.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View v) {
            openUserEnteredAndFinish(mText.getText().toString());
        }
    });

    Resources resources = getResources();

    int padding[] = { mText.getPaddingLeft(), mText.getPaddingTop(), mText.getPaddingRight(),
            mText.getPaddingBottom() };

    GeckoStateListDrawable states = new GeckoStateListDrawable();
    states.initializeFilter(GeckoApp.mBrowserToolbar.getHighlightColor());
    states.addState(new int[] { android.R.attr.state_focused },
            resources.getDrawable(R.drawable.address_bar_url_pressed));
    states.addState(new int[] { android.R.attr.state_pressed },
            resources.getDrawable(R.drawable.address_bar_url_pressed));
    states.addState(new int[] {}, resources.getDrawable(R.drawable.address_bar_url_default));
    mText.setBackgroundDrawable(states);

    mText.setPadding(padding[0], padding[1], padding[2], padding[3]);

    Intent intent = getIntent();
    String currentUrl = intent.getStringExtra(CURRENT_URL_KEY);
    mType = intent.getStringExtra(TYPE_KEY);
    if (currentUrl != null) {
        mText.setText(currentUrl);
        mText.selectAll();
    }

    mText.setOnKeyPreImeListener(new AwesomeBarEditText.OnKeyPreImeListener() {
        public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
            // We only want to process one event per tap
            if (event.getAction() != KeyEvent.ACTION_DOWN)
                return false;

            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                openUserEnteredAndFinish(mText.getText().toString());
                return true;
            }

            // If input method is in fullscreen mode, we want to dismiss
            // it instead of closing awesomebar straight away.
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (keyCode == KeyEvent.KEYCODE_BACK && !imm.isFullscreenMode()) {
                // Let mAwesomeTabs try to handle the back press, since we may be in a
                // bookmarks sub-folder.
                if (mAwesomeTabs.onBackPressed())
                    return true;

                // If mAwesomeTabs.onBackPressed() returned false, we didn't move up
                // a folder level, so just exit the activity.
                cancelAndFinish();
                return true;
            }

            return false;
        }
    });

    mText.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            // do nothing
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // do nothing
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String text = s.toString();

            mAwesomeTabs.filter(text);
            updateGoButton(text);
        }
    });

    mText.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                if (event.getAction() != KeyEvent.ACTION_DOWN)
                    return true;

                openUserEnteredAndFinish(mText.getText().toString());
                return true;
            } else {
                return false;
            }
        }
    });

    mText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }
        }
    });

    registerForContextMenu(mAwesomeTabs.findViewById(R.id.all_pages_list));
    registerForContextMenu(mAwesomeTabs.findViewById(R.id.bookmarks_list));
    registerForContextMenu(mAwesomeTabs.findViewById(R.id.history_list));

    GeckoAppShell.registerGeckoEventListener("SearchEngines:Data", this);
    GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:Get", null));
}

From source file:com.limewoodmedia.nsdroid.fragments.IssueDetailFragment.java

private void showIssueResult(IssueResult result) {
    if (isAdded()) {
        choicesArea.removeAllViews();//  w  w w .java 2s. c  o m
        theIssue.setText(R.string.the_talking_point);
        text.setText(Html.fromHtml(result.result));
        theDebate.setText(R.string.recent_trends);
        RelativeLayout cText;
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);
        params.setMargins(0, 0, 0, 9);
        TextView trend;
        TextView trendName;
        for (CensusChange change : result.censusChangeList) {
            cText = (RelativeLayout) getLayoutInflater(null).inflate(R.layout.recent_trend, null);
            trend = (TextView) cText.findViewById(R.id.trend);
            trend.setText(change.percent);
            trendName = (TextView) cText.findViewById(R.id.trend_name);
            trendName.setText(change.name);
            if (change.increase) {
                trend.setTextColor(getResources().getColor(R.color.medium_green));
                trendName.setTextColor(getResources().getColor(R.color.medium_green));
            } else {
                trend.setTextColor(getResources().getColor(R.color.decrease_red));
                trendName.setTextColor(getResources().getColor(R.color.decrease_red));
            }
            ((TextView) cText.findViewById(R.id.trend_metric)).setText(change.metric);
            choicesArea.addView(cText, params);
            scrollView.scrollTo(0, 0);
        }
    }
}

From source file:com.tencent.wstt.gt.activity.GTPerfFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View perfLayout = inflater.inflate(R.layout.gt_perfactivity, container, false);

    tv_perNoStartToast = (TextView) perfLayout.findViewById(R.id.perf_no_start_toast);

    btn_delete = (ImageButton) perfLayout.findViewById(R.id.perf_delete);
    btn_save = (ImageButton) perfLayout.findViewById(R.id.perf_save);
    btn_start = (ImageButton) perfLayout.findViewById(R.id.perf_start);
    btn_stop = (ImageButton) perfLayout.findViewById(R.id.perf_stop);

    listView = (ListView) perfLayout.findViewById(R.id.perf_list);
    dataSet = GTTimeInternal.getEntrys();
    timeAdapter = new TimeAdapter(dataSet);
    listView.setAdapter(timeAdapter);//w  w  w  .  j  ava  2s.  c  om

    /*
     * ??UI??
     */
    if (GTTimeInternal.isETStarted()) {
        if (dataSet != null && dataSet.length == 0) {
            tv_perNoStartToast.setText(TOAST_STARTED);
            tv_perNoStartToast.setVisibility(View.VISIBLE);
        } else {
            tv_perNoStartToast.setVisibility(View.GONE);
        }

        btn_start.setVisibility(View.INVISIBLE);
        btn_save.setVisibility(View.INVISIBLE);
        btn_delete.setVisibility(View.INVISIBLE);

        btn_stop.setVisibility(View.VISIBLE);
    } else {
        if (dataSet == null || dataSet.length == 0) {
            tv_perNoStartToast.setText(TOAST_NOT_START);
            tv_perNoStartToast.setVisibility(View.VISIBLE);
        } else {
            tv_perNoStartToast.setVisibility(View.GONE);
        }

        btn_start.setVisibility(View.VISIBLE);
        btn_save.setVisibility(View.VISIBLE);
        btn_delete.setVisibility(View.VISIBLE);

        btn_stop.setVisibility(View.INVISIBLE);
    }

    // 
    btn_delete.setOnClickListener(showDeleteDlg);

    /*
     * ?
     */
    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(new OnClickListener() {

        @Override
        public void onClick(View v) {
            et_savePath.setText("");
        }
    });

    et_savePath = (EditText) rl_save.findViewById(R.id.save_editor);
    String lastSaveLog = GTTimeInternal.getLastSaveTimeLog();
    if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.TLOG_POSFIX)) {
        lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    }
    lastSaveLog = lastSaveLog.trim();
    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) {
                    GTTimeInternal.saveTimeLog(et_savePath.getText().toString().trim());
                    dialog.dismiss();
                }
            }).create();

    btn_save.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            String lastSaveLog = GTTimeInternal.getLastSaveTimeLog();
            if (lastSaveLog != null && lastSaveLog.contains(".")
                    && lastSaveLog.endsWith(LogUtils.TLOG_POSFIX)) {
                lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
            }
            et_savePath.setText(lastSaveLog);
            dlg_save.show();
        }
    });

    btn_start.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // UI???save?delete?startend
            if (!GTTimeInternal.isETStarted()) {
                // ??
                if (!GTMemoryDaemonHelper.startGWOrProfValid()) {
                    return;
                }

                btn_start.setVisibility(View.INVISIBLE);
                btn_save.setVisibility(View.INVISIBLE);
                btn_delete.setVisibility(View.INVISIBLE);

                btn_stop.setVisibility(View.VISIBLE);

                // ???
                GTTimeInternal.setETStarted(true);

                handler.postDelayed(task, delaytime);

                if (dataSet != null && dataSet.length == 0) {
                    tv_perNoStartToast.setText(TOAST_STARTED);
                    tv_perNoStartToast.setVisibility(View.VISIBLE);
                } else {
                    tv_perNoStartToast.setVisibility(View.GONE);
                }
            }
        }
    });

    btn_stop.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // UI???save?delete?startend
            if (GTTimeInternal.isETStarted()) {
                btn_save.setVisibility(View.VISIBLE);
                btn_delete.setVisibility(View.VISIBLE);
                btn_start.setVisibility(View.VISIBLE);

                btn_stop.setVisibility(View.INVISIBLE);

                // ???
                GTTimeInternal.setETStarted(false);
                handler.removeCallbacks(task);

                if (dataSet == null || dataSet.length == 0) {
                    tv_perNoStartToast.setText(TOAST_NOT_START);
                    tv_perNoStartToast.setVisibility(View.VISIBLE);
                } else {
                    tv_perNoStartToast.setVisibility(View.GONE);
                }
            }
        }
    });

    return perfLayout;
}

From source file:fr.gotorennes.AbstractMapActivity.java

protected void populateItineraireDetails(Itineraire itineraire) {
    LinearLayout details = (LinearLayout) findViewById(R.id.details);
    for (final Etape etape : itineraire.etapes) {
        addEtapeOverlay(etape);//  www  .j a  v  a  2  s. co m

        RelativeLayout view = (RelativeLayout) getLayoutInflater().inflate(R.layout.itineraire_listitem, null);

        ImageView lineIcon = (ImageView) view.findViewById(R.id.icon);
        if (etape.bitmapIcon != null) {
            lineIcon.setImageBitmap(etape.bitmapIcon);
        } else {
            lineIcon.setImageResource(etape.type.icon);
        }

        TextView name = (TextView) view.findViewById(R.id.name);
        name.setText(Html.fromHtml(Arret.getTime(etape.depart) + " : " + etape.adresseDepart + "<br />"
                + Arret.getTime(etape.arrivee) + " : " + etape.adresseArrivee));

        TextView duree = (TextView) view.findViewById(R.id.duree);
        duree.setText(etape.getDuree() + "min");

        TextView distance = (TextView) view.findViewById(R.id.distance);
        distance.setText(getFormattedDistance(etape.locationDepart, etape.locationArrivee));
        distance.setVisibility(
                etape.type == TypeEtape.PIETON || etape.type == TypeEtape.VELO ? View.VISIBLE : View.GONE);

        view.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Location depart = etape.locationDepart;
                centerMap(depart.latitude, depart.longitude);
            }
        });
        details.addView(view);
    }
    Location first = itineraire.etapes.get(0).locationDepart;
    centerMap(first.latitude, first.longitude);
}

From source file:com.luseen.spacenavigation.SpaceNavigationView.java

/**
 * Update selected item and change it's and non selected item tint
 *
 * @param selectedIndex item in index//from ww  w.  j a v a2 s. c om
 */
private void updateSpaceItems(final int selectedIndex) {

    /**
     * return if item already selected
     */
    if (currentSelectedItem == selectedIndex)
        return;

    /**
     * Change active and inactive icon and text color
     */
    for (int i = 0; i < spaceItemList.size(); i++) {
        if (i == selectedIndex) {
            RelativeLayout textAndIconContainer = (RelativeLayout) spaceItemList.get(selectedIndex);
            ImageView spaceItemIcon = (ImageView) textAndIconContainer.findViewById(R.id.space_icon);
            TextView spaceItemText = (TextView) textAndIconContainer.findViewById(R.id.space_text);
            spaceItemText.setTextColor(activeSpaceItemColor);
            Utils.changeImageViewTint(spaceItemIcon, activeSpaceItemColor);
        } else if (i == currentSelectedItem) {
            RelativeLayout textAndIconContainer = (RelativeLayout) spaceItemList.get(i);
            ImageView spaceItemIcon = (ImageView) textAndIconContainer.findViewById(R.id.space_icon);
            TextView spaceItemText = (TextView) textAndIconContainer.findViewById(R.id.space_text);
            spaceItemText.setTextColor(inActiveSpaceItemColor);
            Utils.changeImageViewTint(spaceItemIcon, inActiveSpaceItemColor);
        }
    }

    /**
     * Set a listener that gets fired when the selected item changes
     *
     * @param listener a listener for monitoring changes in item selection
     */
    if (spaceOnClickListener != null)
        spaceOnClickListener.onItemClick(selectedIndex, spaceItems.get(selectedIndex).getItemName());

    /**
     * Change current selected item index
     */
    currentSelectedItem = selectedIndex;
}

From source file:com.forrestguice.suntimeswidget.EquinoxView.java

private void init(Context context, AttributeSet attrs) {
    initLocale(context);/* w w  w .  j a  v  a  2s .  co  m*/
    initColors(context);
    LayoutInflater.from(context).inflate(R.layout.layout_view_equinox, this, true);

    if (attrs != null) {
        LinearLayout.LayoutParams lp = generateLayoutParams(attrs);
        centered = ((lp.gravity == Gravity.CENTER) || (lp.gravity == Gravity.CENTER_HORIZONTAL));
    }

    empty = (TextView) findViewById(R.id.txt_empty);

    flipper = (ViewFlipper) findViewById(R.id.info_equinoxsolstice_flipper);
    flipper.setOnTouchListener(cardTouchListener);

    notes = new ArrayList<EquinoxNote>();

    RelativeLayout thisYear = (RelativeLayout) findViewById(R.id.info_equinoxsolstice_thisyear);
    if (thisYear != null) {
        btn_flipperNext_thisYear = (ImageButton) thisYear.findViewById(R.id.info_time_nextbtn);
        btn_flipperNext_thisYear.setOnClickListener(onNextCardClick);
        btn_flipperNext_thisYear.setOnTouchListener(createButtonListener(btn_flipperNext_thisYear));

        btn_flipperPrev_thisYear = (ImageButton) thisYear.findViewById(R.id.info_time_prevbtn);
        btn_flipperPrev_thisYear.setVisibility(View.GONE);

        titleThisYear = (TextView) thisYear.findViewById(R.id.text_title);

        TextView txt_equinox_vernal_label = (TextView) thisYear
                .findViewById(R.id.text_date_equinox_vernal_label);
        TextView txt_equinox_vernal = (TextView) thisYear.findViewById(R.id.text_date_equinox_vernal);
        TextView txt_equinox_vernal_note = (TextView) thisYear.findViewById(R.id.text_date_equinox_vernal_note);
        note_equinox_vernal = addNote(txt_equinox_vernal_label, txt_equinox_vernal, txt_equinox_vernal_note, 0);

        TextView txt_solstice_summer_label = (TextView) thisYear
                .findViewById(R.id.text_date_solstice_summer_label);
        TextView txt_solstice_summer = (TextView) thisYear.findViewById(R.id.text_date_solstice_summer);
        TextView txt_solstice_summer_note = (TextView) thisYear
                .findViewById(R.id.text_date_solstice_summer_note);
        note_solstice_summer = addNote(txt_solstice_summer_label, txt_solstice_summer, txt_solstice_summer_note,
                0);

        TextView txt_equinox_autumnal_label = (TextView) thisYear
                .findViewById(R.id.text_date_equinox_autumnal_label);
        TextView txt_equinox_autumnal = (TextView) thisYear.findViewById(R.id.text_date_equinox_autumnal);
        TextView txt_equinox_autumnal_note = (TextView) thisYear
                .findViewById(R.id.text_date_equinox_autumnal_note);
        note_equinox_autumnal = addNote(txt_equinox_autumnal_label, txt_equinox_autumnal,
                txt_equinox_autumnal_note, 0);

        TextView txt_solstice_winter_label = (TextView) thisYear
                .findViewById(R.id.text_date_solstice_winter_label);
        TextView txt_solstice_winter = (TextView) thisYear.findViewById(R.id.text_date_solstice_winter);
        TextView txt_solstice_winter_note = (TextView) thisYear
                .findViewById(R.id.text_date_solstice_winter_note);
        note_solstice_winter = addNote(txt_solstice_winter_label, txt_solstice_winter, txt_solstice_winter_note,
                0);

        if (centered) {
            FrameLayout.LayoutParams lpThisYear = (FrameLayout.LayoutParams) thisYear.getLayoutParams();
            lpThisYear.gravity = Gravity.CENTER_HORIZONTAL;
            thisYear.setLayoutParams(lpThisYear);
        }
    }

    RelativeLayout nextYear = (RelativeLayout) findViewById(R.id.info_equinoxsolstice_nextyear);
    if (nextYear != null) {
        btn_flipperNext_nextYear = (ImageButton) nextYear.findViewById(R.id.info_time_nextbtn);
        btn_flipperNext_nextYear.setVisibility(View.GONE);

        btn_flipperPrev_nextYear = (ImageButton) nextYear.findViewById(R.id.info_time_prevbtn);
        btn_flipperPrev_nextYear.setOnClickListener(onPrevCardClick);
        btn_flipperPrev_nextYear.setOnTouchListener(createButtonListener(btn_flipperPrev_nextYear));

        titleNextYear = (TextView) nextYear.findViewById(R.id.text_title);

        TextView txt_equinox_vernal2_label = (TextView) nextYear
                .findViewById(R.id.text_date_equinox_vernal_label);
        TextView txt_equinox_vernal2 = (TextView) nextYear.findViewById(R.id.text_date_equinox_vernal);
        TextView txt_equinox_vernal2_note = (TextView) nextYear
                .findViewById(R.id.text_date_equinox_vernal_note);
        note_equinox_vernal2 = addNote(txt_equinox_vernal2_label, txt_equinox_vernal2, txt_equinox_vernal2_note,
                1);

        TextView txt_solstice_summer2_label = (TextView) nextYear
                .findViewById(R.id.text_date_solstice_summer_label);
        TextView txt_solstice_summer2 = (TextView) nextYear.findViewById(R.id.text_date_solstice_summer);
        TextView txt_solstice_summer2_note = (TextView) nextYear
                .findViewById(R.id.text_date_solstice_summer_note);
        note_solstice_summer2 = addNote(txt_solstice_summer2_label, txt_solstice_summer2,
                txt_solstice_summer2_note, 1);

        TextView txt_equinox_autumnal2_label = (TextView) nextYear
                .findViewById(R.id.text_date_equinox_autumnal_label);
        TextView txt_equinox_autumnal2 = (TextView) nextYear.findViewById(R.id.text_date_equinox_autumnal);
        TextView txt_equinox_autumnal2_note = (TextView) nextYear
                .findViewById(R.id.text_date_equinox_autumnal_note);
        note_equinox_autumnal2 = addNote(txt_equinox_autumnal2_label, txt_equinox_autumnal2,
                txt_equinox_autumnal2_note, 1);

        TextView txt_solstice_winter2_label = (TextView) nextYear
                .findViewById(R.id.text_date_solstice_winter_label);
        TextView txt_solstice_winter2 = (TextView) nextYear.findViewById(R.id.text_date_solstice_winter);
        TextView txt_solstice_winter2_note = (TextView) nextYear
                .findViewById(R.id.text_date_solstice_winter_note);
        note_solstice_winter2 = addNote(txt_solstice_winter2_label, txt_solstice_winter2,
                txt_solstice_winter2_note, 1);

        if (centered) {
            FrameLayout.LayoutParams lpNextYear = (FrameLayout.LayoutParams) nextYear.getLayoutParams();
            lpNextYear.gravity = Gravity.CENTER_HORIZONTAL;
            nextYear.setLayoutParams(lpNextYear);
        }
    }

    if (isInEditMode()) {
        updateViews(context, null);
    }
}