Example usage for android.widget FrameLayout findViewById

List of usage examples for android.widget FrameLayout findViewById

Introduction

In this page you can find the example usage for android.widget FrameLayout 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:org.wingy.jp8chan.ui.activity.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);

    super.onCreate(savedInstanceState);

    if (postAdapter == null) {
        Logger.e(TAG, "Posts in ImageViewActivity was null");
        finish();/*from   w w w  .j a  va2 s  . c  om*/
        return;
    }

    threadManager = threadManagerStatic;

    ThemeHelper.setTheme(this);

    progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_no_bg));
    progressBar.setIndeterminate(false);
    progressBar.setMax(1000000);

    final FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
    decorView.addView(progressBar);

    progressBar.post(new Runnable() {
        @Override
        public void run() {
            View contentView = decorView.findViewById(android.R.id.content);
            progressBar.setY(contentView.getY() - progressBar.getHeight() / 2);
        }
    });

    // Get the posts with images
    ArrayList<Post> imagePosts = new ArrayList<>();
    for (Post post : postAdapter.getList()) {
        if (post.hasImage) {
            imagePosts.add(post);
        }
    }

    // Setup our pages and adapter
    setContentView(R.layout.image_pager);
    viewPager = (ViewPager) findViewById(R.id.image_pager);
    adapter = new ImageViewAdapter(getFragmentManager(), this);
    adapter.setList(imagePosts);
    viewPager.setAdapter(adapter);
    viewPager.setOnPageChangeListener(this);

    // Select the right image
    for (int i = 0; i < imagePosts.size(); i++) {
        if (imagePosts.get(i).no == selectedId) {
            viewPager.setCurrentItem(i);
            onPageSelected(i);
            break;
        }
    }
}

From source file:org.floens.chan.ui.activity.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);

    super.onCreate(savedInstanceState);

    if (postAdapterStatic == null || threadManagerStatic == null) {
        Logger.e(TAG, "postadapter or threadmanager null");
        finish();/*www  . j  a  v  a2 s.com*/
        return;
    }

    threadManager = threadManagerStatic;
    threadManagerStatic = null;
    postAdapter = postAdapterStatic;
    postAdapterStatic = null;
    int selectedId = selectedIdStatic;
    selectedIdStatic = -1;

    ThemeHelper.setTheme(this);

    progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_no_bg));
    progressBar.setIndeterminate(false);
    progressBar.setMax(1000000);

    final FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
    decorView.addView(progressBar);

    progressBar.post(new Runnable() {
        @Override
        public void run() {
            View contentView = decorView.findViewById(android.R.id.content);
            progressBar.setY(contentView.getY() - progressBar.getHeight() / 2);
        }
    });

    // Get the posts with images
    ArrayList<Post> imagePosts = new ArrayList<>();
    for (Post post : postAdapter.getList()) {
        if (post.hasImage) {
            imagePosts.add(post);
        }
    }

    // Setup our pages and adapter
    setContentView(R.layout.image_pager);
    viewPager = (ViewPager) findViewById(R.id.image_pager);
    adapter = new ImageViewAdapter(getFragmentManager(), this);
    adapter.setList(imagePosts);
    viewPager.setAdapter(adapter);
    viewPager.setOnPageChangeListener(this);

    // Select the right image
    for (int i = 0; i < imagePosts.size(); i++) {
        if (imagePosts.get(i).no == selectedId) {
            viewPager.setCurrentItem(i);
            onPageSelected(i);
            break;
        }
    }
}

From source file:com.nextgis.mobile.MapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mContext = getActivity().getApplicationContext();

    if (mMap == null) {
        MainActivity activity = (MainActivity) getActivity();
        mMap = activity.getMap();//from  w w  w .j  av a 2  s .c  o  m
        mMap.addListener(this);
    }

    View view = inflater.inflate(R.layout.mapfragment, container, false);
    FrameLayout layout = (FrameLayout) view.findViewById(R.id.mapholder);
    //search relative view of map, if not found - add it
    if (mMap != null) {
        mMapRelativeLayout = (RelativeLayout) layout.findViewById(R.id.maprl);
        if (mMapRelativeLayout != null) {
            mMapRelativeLayout.addView(mMap, new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
            addMapButtons(mMapRelativeLayout);
        } // layout.addView(mMap);//.getRelativeLayout());
    }

    mInfoPane = inflater.inflate(R.layout.infopane, null, true);

    mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
    mChangeLocationListener = new ChangeLocationListener();
    mGpsStatusListener = new GpsStatusListener();

    return view;
}

From source file:org.bohrmeista.chan.ui.activity.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);

    super.onCreate(savedInstanceState);

    if (postAdapter == null) {
        Logger.e(TAG, "Posts in ImageViewActivity was null");
        finish();//  w  w  w  . java 2s .  c o m
        return;
    }

    threadManager = threadManagerStatic;

    ThemeHelper.setTheme(this);

    progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_no_bg));
    progressBar.setIndeterminate(false);
    progressBar.setMax(1000000);

    final FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
    decorView.addView(progressBar);

    progressBar.post(new Runnable() {
        @Override
        public void run() {
            View contentView = decorView.findViewById(android.R.id.content);
            progressBar.setY(contentView.getY() - progressBar.getHeight() / 2);
        }
    });

    // Get the posts with images
    ArrayList<Post> imagePosts = new ArrayList<>();
    for (Post post : postAdapter.getList()) {
        if (post.images.size() > 0) {
            imagePosts.add(post);
        }
    }

    // Setup our pages and adapter
    setContentView(R.layout.image_pager);
    viewPager = (ViewPager) findViewById(R.id.image_pager);
    imageAdapter = new ImageViewAdapter(getFragmentManager(), this);
    imageAdapter.setList(imagePosts);
    viewPager.setAdapter(imageAdapter);
    viewPager.setOnPageChangeListener(this);

    // Select the right image
    int imageIndex = 0;
    for (Post post : imagePosts) {
        if (post.no == selectedId) {
            viewPager.setCurrentItem(imageIndex);
            onPageSelected(imageIndex);

            thumbList = (TwoWayView) findViewById(R.id.thumbList);
            thumbListAdapter = new ThumbListAdapter(this, post.images, imageIndex);
            thumbList.setAdapter(thumbListAdapter);
            thumbList.setVisibility(post.images.size() <= 1 ? View.GONE : View.VISIBLE);
            return;
        }
        imageIndex += post.images.size();
    }
}

From source file:com.alexive.graphicalutils.fragments.RecyclerViewFragment.java

/**
 * Sets a view to be displayed when the list is empty with optional LayoutParams.
 * @param view Displayed when the list is empty.
 * @param params Information about how view's layout in the countainer.
 *///from w  w  w  . java 2s.c o m
public void setEmptyView(View view, FrameLayout.LayoutParams params) {
    emptyView = view;
    isEmptyViewEmptyText = true;
    FrameLayout frameLayout = (FrameLayout) getView();
    if (frameLayout == null)
        return;
    //In order to avoid having more than one emptyViews added to the layout
    if (frameLayout.getChildCount() > 2)
        frameLayout.removeViewAt(2);
    if (this.emptyText != null)
        frameLayout.findViewById(android.R.id.text1).setVisibility(View.GONE);
    if (params == null) {
        params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.CENTER;
    }

    frameLayout.addView(view, 1, params);
    this.emptyViewAddedToLayout = true;
    actuallySetEmptyView();
}

From source file:org.deviceconnect.android.uiapp.fragment.profile.NetworkServiceDiscoveryProfileFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    mLogger.entering(getClass().getName(), "onCreateView",
            new Object[] { inflater, container, savedInstanceState });
    final Context context = getActivity();

    FrameLayout lframe = new FrameLayout(context);

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);/*from  w w w . ja va 2  s.c o m*/
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    lframe.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    mListView = (ListView) lframe.findViewById(android.R.id.list);
    mListView.setAdapter(new ArrayAdapter<SmartDevice>(getActivity(), android.R.layout.simple_list_item_1));

    (new ServiceDiscoveryTask()).execute();

    mLogger.exiting(getClass().getName(), "onCreateView", mListView);
    return lframe;
}

From source file:com.farmerbb.taskbar.service.DashboardService.java

private void hideDashboard() {
    if (layout.getVisibility() == View.VISIBLE) {
        layout.setOnClickListener(null);
        fadeOut(true);//from   ww  w.jav  a 2s .c  o m

        for (int i = 0; i < maxSize; i++) {
            FrameLayout frameLayout = cells.get(i);
            frameLayout.findViewById(R.id.empty).setVisibility(View.GONE);
        }

        previouslySelectedCell = -1;
    }
}

From source file:com.eng.arab.translator.androidtranslator.activity.NumberViewActivity.java

public void displayDialog(String vid) {
    if (getResources().getIdentifier(vid, "raw", getPackageName()) == 0) {
        /* TEST if RAW file doesn't exist then do nothing*/
    } else {/*from   w ww.  ja  va  2 s  .  co m*/
        final Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
        dialog.setContentView(R.layout.number_video_view);
        dialog.setCancelable(false);
        dialog.setCanceledOnTouchOutside(true);

        mVideoView = (VideoView) dialog.findViewById(R.id.videoView);
        mVideoView.setZOrderMediaOverlay(true);
        String path = "android.resource://" + getPackageName() + "/" + //R.raw.alif;
                getResources().getIdentifier(vid, "raw", getPackageName());

        FrameLayout fl = (FrameLayout) dialog.findViewById(R.id.VideoFrameLayout);
        ImageButton imageButtonClose = (ImageButton) fl.findViewById(R.id.imageButtonClose);
        imageButtonClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //dialog.dismiss();
                if (v.getId() == R.id.imageButtonClose) {
                    dialog.dismiss();
                }
            }
            // Perform button logic
        });

        // Set the media controller buttons
        if (mediaController == null) {
            mediaController = new MediaController(NumberViewActivity.this);

            // Set the videoView that acts as the anchor for the MediaController.
            mediaController.setAnchorView(mVideoView);

            // Set MediaController for VideoView
            mVideoView.setMediaController(mediaController);
        }

        mVideoView.setVideoURI(Uri.parse(path));
        mVideoView.requestFocus();

        // When the video file ready for playback.
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            public void onPrepared(MediaPlayer mediaPlayer) {
                mVideoView.seekTo(position);
                if (position == 0) {
                    mVideoView.start();
                }
                // When video Screen change size.
                mediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
                    @Override
                    public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {

                        // Re-Set the videoView that acts as the anchor for the MediaController
                        mediaController.setAnchorView(mVideoView);
                    }
                });
            }
        });
        dialog.show();
    }
}

From source file:com.farmerbb.taskbar.service.DashboardService.java

private void cellClick(View view, boolean isActualClick) {
    Bundle bundle = (Bundle) view.getTag();
    int cellId = bundle.getInt("cellId");
    int appWidgetId = bundle.getInt("appWidgetId", -1);

    int currentlySelectedCell = appWidgetId == -1 ? cellId : -1;

    SharedPreferences pref = U.getSharedPreferences(this);
    boolean shouldShowPlaceholder = pref
            .getBoolean("dashboard_widget_" + Integer.toString(cellId) + "_placeholder", false);
    if (isActualClick && ((appWidgetId == -1 && currentlySelectedCell == previouslySelectedCell)
            || shouldShowPlaceholder)) {
        fadeOut(false);//  w  w  w .  java2 s.  c o  m

        FrameLayout frameLayout = cells.get(currentlySelectedCell);
        frameLayout.findViewById(R.id.empty).setVisibility(View.GONE);

        Intent intent = new Intent("com.farmerbb.taskbar.ADD_WIDGET_REQUESTED");
        intent.putExtra("appWidgetId", APPWIDGET_HOST_ID);
        intent.putExtra("cellId", cellId);
        LocalBroadcastManager.getInstance(DashboardService.this).sendBroadcast(intent);

        if (shouldShowPlaceholder) {
            String providerName = pref.getString("dashboard_widget_" + Integer.toString(cellId) + "_provider",
                    "null");
            if (!providerName.equals("null")) {
                ComponentName componentName = ComponentName.unflattenFromString(providerName);

                List<AppWidgetProviderInfo> providerInfoList = mAppWidgetManager
                        .getInstalledProvidersForProfile(Process.myUserHandle());
                for (AppWidgetProviderInfo info : providerInfoList) {
                    if (info.provider.equals(componentName)) {
                        U.showToast(this,
                                getString(R.string.widget_restore_toast, info.loadLabel(getPackageManager())),
                                Toast.LENGTH_SHORT);
                        break;
                    }
                }
            }
        }

        previouslySelectedCell = -1;
    } else {
        for (int i = 0; i < maxSize; i++) {
            FrameLayout frameLayout = cells.get(i);
            frameLayout.findViewById(R.id.empty).setVisibility(
                    i == currentlySelectedCell && !shouldShowPlaceholder ? View.VISIBLE : View.GONE);
        }

        previouslySelectedCell = currentlySelectedCell;
    }
}

From source file:org.apps8os.motivator.ui.MainActivity.java

/**
 * Showing the guide of the main sections in the application
 *//*from  ww  w .ja va2s  .  c o  m*/
public void showHelp() {
    if (!mHelpIsVisible) {
        mHelpIsVisible = true;
        mViewPager.setCurrentItem(1);
        final FrameLayout contentRoot = (FrameLayout) findViewById(R.id.root_view);
        // Inflate the help overlay to the fragment.
        getLayoutInflater().inflate(R.layout.element_help_overlay, contentRoot, true);

        final TextView helpTitle = (TextView) contentRoot.findViewById(R.id.help_overlay_title);
        helpTitle.setText(getString(R.string.today_section));
        final TextView helpText = (TextView) contentRoot.findViewById(R.id.help_overlay_subtitle);
        helpText.setText(getString(R.string.today_section_help));
        final LinearLayout helpBackground = (LinearLayout) contentRoot.findViewById(R.id.help_text_background);
        helpBackground.setBackgroundResource(R.color.actionbar_green);
        ((Button) contentRoot.findViewById(R.id.help_overlay_button)).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mViewPager.getCurrentItem() == 0) {
                    final View helpOverlay = (View) contentRoot.findViewById(R.id.help_overlay);
                    helpOverlay.animate().alpha(0f).setDuration(500).setListener(new AnimatorListenerAdapter() {

                        // Set the visibility to gone when animation has ended.
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            helpOverlay.setVisibility(View.GONE);
                            contentRoot.removeView(helpOverlay);
                        }
                    });
                    mViewPager.setCurrentItem(1);

                    SharedPreferences.Editor editor = mPrefs.edit();
                    editor.putBoolean(SEEN_HELP, true);
                    editor.commit();
                    mHelpIsVisible = false;
                } else if (mViewPager.getCurrentItem() == 1) {
                    mViewPager.setCurrentItem(2);
                    helpTitle.setText(getString(R.string.plan_section));
                    helpText.setText(getString(R.string.plan_section_help));
                    helpBackground.setBackgroundResource(R.color.actionbar_blue);
                } else {
                    mViewPager.setCurrentItem(0);
                    helpTitle.setText(getString(R.string.history_section));
                    helpText.setText(getString(R.string.history_section_help));
                    helpBackground.setBackgroundResource(R.color.actionbar_orange);
                    ((Button) contentRoot.findViewById(R.id.help_overlay_button))
                            .setText(getString(R.string.ok));
                }
            }
        });
    }
}