Example usage for android.widget FrameLayout FrameLayout

List of usage examples for android.widget FrameLayout FrameLayout

Introduction

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

Prototype

public FrameLayout(@NonNull Context context) 

Source Link

Usage

From source file:org.telegram.ui.ThemePreviewActivity.java

@Override
public View createView(Context context) {
    page1 = new FrameLayout(context);
    ActionBarMenu menu = actionBar.createMenu();
    final ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true)
            .setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
                @Override/*w  w w . ja v  a 2s. co m*/
                public void onSearchExpand() {

                }

                @Override
                public boolean canCollapseSearch() {
                    return true;
                }

                @Override
                public void onSearchCollapse() {

                }

                @Override
                public void onTextChanged(EditText editText) {

                }
            });
    item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));

    actionBar.setBackButtonDrawable(new MenuDrawable());
    actionBar.setAddToContainer(false);
    actionBar.setTitle(LocaleController.getString("ThemePreview", R.string.ThemePreview));

    page1 = new FrameLayout(context) {
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int widthSize = MeasureSpec.getSize(widthMeasureSpec);
            int heightSize = MeasureSpec.getSize(heightMeasureSpec);

            setMeasuredDimension(widthSize, heightSize);

            measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
            int actionBarHeight = actionBar.getMeasuredHeight();
            if (actionBar.getVisibility() == VISIBLE) {
                heightSize -= actionBarHeight;
            }
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
            layoutParams.topMargin = actionBarHeight;
            listView.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY));

            measureChildWithMargins(floatingButton, widthMeasureSpec, 0, heightMeasureSpec, 0);
        }

        @Override
        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
            boolean result = super.drawChild(canvas, child, drawingTime);
            if (child == actionBar && parentLayout != null) {
                parentLayout.drawHeaderShadow(canvas,
                        actionBar.getVisibility() == VISIBLE ? actionBar.getMeasuredHeight() : 0);
            }
            return result;
        }
    };
    page1.addView(actionBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    listView = new RecyclerListView(context);
    listView.setVerticalScrollBarEnabled(true);
    listView.setItemAnimator(null);
    listView.setLayoutAnimation(null);
    listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    listView.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT
            : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
    page1.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT,
            Gravity.LEFT | Gravity.TOP));

    floatingButton = new ImageView(context);
    floatingButton.setScaleType(ImageView.ScaleType.CENTER);

    Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56),
            Theme.getColor(Theme.key_chats_actionBackground),
            Theme.getColor(Theme.key_chats_actionPressedBackground));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
        drawable = combinedDrawable;
    }
    floatingButton.setBackgroundDrawable(drawable);
    floatingButton.setColorFilter(
            new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
    floatingButton.setImageResource(R.drawable.floating_pencil);
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed },
                ObjectAnimator
                        .ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4))
                        .setDuration(200));
        animator.addState(new int[] {},
                ObjectAnimator
                        .ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2))
                        .setDuration(200));
        floatingButton.setStateListAnimator(animator);
        floatingButton.setOutlineProvider(new ViewOutlineProvider() {
            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
            }
        });
    }
    page1.addView(floatingButton,
            LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60,
                    Build.VERSION.SDK_INT >= 21 ? 56 : 60,
                    (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM,
                    LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 14));

    dialogsAdapter = new DialogsAdapter(context);
    listView.setAdapter(dialogsAdapter);

    page2 = new SizeNotifierFrameLayout(context) {
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int widthSize = MeasureSpec.getSize(widthMeasureSpec);
            int heightSize = MeasureSpec.getSize(heightMeasureSpec);

            setMeasuredDimension(widthSize, heightSize);

            measureChildWithMargins(actionBar2, widthMeasureSpec, 0, heightMeasureSpec, 0);
            int actionBarHeight = actionBar2.getMeasuredHeight();
            if (actionBar2.getVisibility() == VISIBLE) {
                heightSize -= actionBarHeight;
            }
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView2.getLayoutParams();
            layoutParams.topMargin = actionBarHeight;
            listView2.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY));
        }

        @Override
        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
            boolean result = super.drawChild(canvas, child, drawingTime);
            if (child == actionBar2 && parentLayout != null) {
                parentLayout.drawHeaderShadow(canvas,
                        actionBar2.getVisibility() == VISIBLE ? actionBar2.getMeasuredHeight() : 0);
            }
            return result;
        }
    };
    page2.setBackgroundImage(Theme.getCachedWallpaper());

    actionBar2 = createActionBar(context);
    actionBar2.setBackButtonDrawable(new BackDrawable(false));
    actionBar2.setTitle("Reinhardt");
    actionBar2.setSubtitle(LocaleController.formatDateOnline(System.currentTimeMillis() / 1000 - 60 * 60));
    page2.addView(actionBar2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    listView2 = new RecyclerListView(context);
    listView2.setVerticalScrollBarEnabled(true);
    listView2.setItemAnimator(null);
    listView2.setLayoutAnimation(null);
    listView2.setPadding(0, AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4));
    listView2.setClipToPadding(false);
    listView2.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true));
    listView2.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT
            : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
    page2.addView(listView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT,
            Gravity.LEFT | Gravity.TOP));

    messagesAdapter = new MessagesAdapter(context);
    listView2.setAdapter(messagesAdapter);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;

    final ViewPager viewPager = new ViewPager(context);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            dotsContainer.invalidate();
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    viewPager.setAdapter(new PagerAdapter() {

        @Override
        public int getCount() {
            return 2;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return object == view;
        }

        @Override
        public int getItemPosition(Object object) {
            return POSITION_UNCHANGED;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            View view = position == 0 ? page1 : page2;
            container.addView(view);
            return view;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

        @Override
        public void unregisterDataSetObserver(DataSetObserver observer) {
            if (observer != null) {
                super.unregisterDataSetObserver(observer);
            }
        }
    });
    AndroidUtilities.setViewPagerEdgeEffectColor(viewPager, Theme.getColor(Theme.key_actionBarDefault));
    frameLayout.addView(viewPager, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 48));

    View shadow = new View(context);
    shadow.setBackgroundResource(R.drawable.header_shadow_reverse);
    frameLayout.addView(shadow,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.LEFT | Gravity.BOTTOM, 0, 0, 0, 48));

    FrameLayout bottomLayout = new FrameLayout(context);
    bottomLayout.setBackgroundColor(0xffffffff);
    frameLayout.addView(bottomLayout,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM));

    dotsContainer = new View(context) {

        private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        @Override
        protected void onDraw(Canvas canvas) {
            int selected = viewPager.getCurrentItem();
            for (int a = 0; a < 2; a++) {
                paint.setColor(a == selected ? 0xff999999 : 0xffcccccc);
                canvas.drawCircle(AndroidUtilities.dp(3 + 15 * a), AndroidUtilities.dp(4),
                        AndroidUtilities.dp(3), paint);
            }
        }
    };
    bottomLayout.addView(dotsContainer, LayoutHelper.createFrame(22, 8, Gravity.CENTER));

    TextView cancelButton = new TextView(context);
    cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    cancelButton.setTextColor(0xff19a7e8);
    cancelButton.setGravity(Gravity.CENTER);
    cancelButton.setBackgroundDrawable(Theme.createSelectorDrawable(0x2f000000, 0));
    cancelButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
    cancelButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    bottomLayout.addView(cancelButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Theme.applyPreviousTheme();
            parentLayout.rebuildAllFragmentViews(false);
            finishFragment();
        }
    });

    TextView doneButton = new TextView(context);
    doneButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    doneButton.setTextColor(0xff19a7e8);
    doneButton.setGravity(Gravity.CENTER);
    doneButton.setBackgroundDrawable(Theme.createSelectorDrawable(0x2f000000, 0));
    doneButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    doneButton.setText(LocaleController.getString("ApplyTheme", R.string.ApplyTheme).toUpperCase());
    doneButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    bottomLayout.addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT));
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            applied = true;
            parentLayout.rebuildAllFragmentViews(false);
            Theme.applyThemeFile(themeFile, applyingTheme.name, false);
            finishFragment();
        }
    });

    return fragmentView;
}

From source file:org.klnusbaum.udj.PullToRefresh.RefreshableListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//from w  ww  .  j  a  v  a2  s  . co  m
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ListView lv = new ListView(getActivity());
    PullToRefreshListView lv = (PullToRefreshListView) inflater.inflate(R.layout.pull_to_refresh_listview,
            null);
    pullToRefreshView = lv;
    lv.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
            // Do work to refresh the list here.
            doRefreshWork();
        }
    });
    // lv.setId(android.R.id.list);
    // lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    return root;
}

From source file:com.github.jvanhie.discogsscrobbler.RecentlyPlayedFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //setup list view
    mList = new ListView(getActivity());
    mList.setId(android.R.id.list);/*from ww  w .j  a  v a 2  s . c o m*/

    mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            onListItemClick(view, i, l);
        }
    });

    //create superframe for adding list and empty view
    FrameLayout superFrame = new FrameLayout(getActivity());
    FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    superFrame.setLayoutParams(layoutparams);
    View emptyView = inflater.inflate(R.layout.fragment_empty, container, false);
    ((TextView) emptyView.findViewById(R.id.empty_heading)).setText("No recently played albums");
    ((TextView) emptyView.findViewById(R.id.empty_text)).setText(
            "Your recently played list is empty. Once you start registering your played records they'll end up here");

    /*initialize list with local discogs collection*/
    if (mDiscogs == null)
        mDiscogs = Discogs.getInstance(getActivity());
    loadList();

    superFrame.addView(emptyView);
    mList.setEmptyView(emptyView);
    superFrame.addView(mList);

    return superFrame;
}

From source file:com.longle1.facedetection.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Hide the window title.
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    super.onCreate(savedInstanceState);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // Create our Preview view and set it as the content of our activity.
    try {//  w  ww.  j  a v a  2s  . c  o  m
        layout = new FrameLayout(this);
        mFaceDetect = new FaceDetect(this);
        mCameraPreview = new CameraPreview(this, mFaceDetect);
        layout.addView(mCameraPreview);
        layout.addView(mFaceDetect);
        setContentView(layout);
    } catch (IOException e) {
        e.printStackTrace();
        new AlertDialog.Builder(this).setMessage(e.getMessage()).create().show();
    }
}

From source file:com.goliathonline.android.kegbot.ui.StarredActivity.java

/**
 * Build and add "vendors" tab./* w  w w .  j a  va2 s.co m*/
 */
private void setupKegsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_kegs);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final Intent intent = new Intent(Intent.ACTION_VIEW, Kegs.CONTENT_STARRED_URI);

    final FragmentManager fm = getSupportFragmentManager();

    mKegsFragment = (KegsFragment) fm.findFragmentByTag("kegs");
    if (mKegsFragment == null) {
        mKegsFragment = new KegsFragment();
        mKegsFragment.setArguments(intentToFragmentArguments(intent));
        fm.beginTransaction().add(R.id.fragment_kegs, mKegsFragment, "kegs").commit();
    }

    // Vendors content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_KEGS).setIndicator(buildIndicator(R.string.starred_kegs))
            .setContent(R.id.fragment_kegs));
}

From source file:com.ehelp.home.SuperAwesomeCardFragment.java

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

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/* w  ww  . j av a2s  .c o m*/
    //fl.setBackgroundColor(0x666666);
    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setGravity(Gravity.TOP);
    System.out.println(position);
    if (position == 0) {
        fl.removeAllViews();
        mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;
        mMapView = new MapView(getActivity());
        mMapView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));
        fl.addView(mMapView);
        mBaiduMap = mMapView.getMap();
        // ??
        mBaiduMap.setMyLocationEnabled(true);
        // ??
        mLocClient = new LocationClient(getActivity());
        mLocClient.registerLocationListener(myListener);
        LocationClientOption option = new LocationClientOption();
        option.setOpenGps(true);// gps
        option.setCoorType("bd09ll"); // ??
        option.setScanSpan(1000);
        mLocClient.setLocOption(option);
        mLocClient.start();
        int count = mMapView.getChildCount();
        for (int i = 0; i < count; i++) {
            View child = mMapView.getChildAt(i);
            if (child instanceof ZoomControls || child instanceof ImageView) {
                child.setVisibility(View.INVISIBLE);
            }
        }
        setLocation();
    } else if (position == 1) {
        fl.removeAllViews();
        ListView queList = new ListView(getActivity());
        queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
        HomeAdapter que = new HomeAdapter(getActivity(), user_id, 2, eventCache);
        queList.setAdapter(que);
        queList.setDividerHeight(20);
        fl.addView(queList);

        events = que.getEvent();

        //?
        queList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
                Intent intent = new Intent(getActivity(), recievesos_map.class);
                int eventid = events.get(index).getEventId();
                intent.putExtra(EXTRA_MESSAGE, eventid);
                startActivity(intent);
            }
        });
    } else if (position == 2) {
        fl.removeAllViews();
        ListView queList = new ListView(getActivity());
        queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
        //queList.setBackgroundColor(0x666666);
        //queList.setAlpha(125);
        queList.setDividerHeight(20);
        HomeAdapter que = new HomeAdapter(getActivity(), user_id, 1, eventCache);
        queList.setAdapter(que);
        fl.addView(queList);

        events = que.getEvent();

        //?
        queList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
                Intent intent = new Intent(getActivity(), recieve_help_ans_map.class);
                intent.putExtra(EXTRA_MESSAGE, events.get(index));
                startActivity(intent);
            }
        });
    } else if (position == 3) {
        fl.removeAllViews();
        ListView queList = new ListView(getActivity());
        queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
        HomeAdapter que = new HomeAdapter(getActivity(), user_id, 0, eventCache);
        queList.setAdapter(que);
        queList.setDividerHeight(20);
        fl.addView(queList);

        events = que.getEvent();

        //?
        queList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
                Intent intent = new Intent(getActivity(), QuestionDetail.class);
                intent.putExtra("qusetiondatail", events.get(index));
                startActivity(intent);
            }
        });
    }
    return fl;
}

From source file:com.bringcommunications.etherpay.SendActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overlay_frame_layout = new FrameLayout(getApplicationContext());
    setContentView(overlay_frame_layout);
    ////w ww.j a  v a2  s  .com
    context = this;
    hex = new Hex();
    preferences = getSharedPreferences("etherpay.bringcommunications.com", MODE_PRIVATE);
    private_key = preferences.getString("key", private_key);
    acct_addr = preferences.getString("acct_addr", acct_addr);
    long wei_balance = preferences.getLong("balance", 0);
    eth_balance = (float) wei_balance / Util.WEI_PER_ETH;
    price = preferences.getFloat("price", price);
    show_gas = preferences.getBoolean("show_gas", show_gas);
    show_data = preferences.getBoolean("show_data", show_data);
    boolean denomination_eth = preferences.getBoolean("denomination_eth", true);
    System.out.println("denomination_eth is " + denomination_eth);
    denomination = denomination_eth ? Denomination.ETH : Denomination.FINNEY;
    auto_pay = getIntent().getStringExtra("AUTO_PAY");
    to_addr = getIntent().getStringExtra("TO_ADDR");
    String size_str = getIntent().getStringExtra("SIZE");
    eth_size = Float.valueOf(size_str);
    data = getIntent().getStringExtra("DATA");
    send_is_done = false;
    //
    View activity_send_view = getLayoutInflater().inflate(R.layout.activity_send, overlay_frame_layout, false);
    setContentView(activity_send_view);
    //
    Spinner dropdown = (Spinner) findViewById(R.id.denomination);
    String[] items = new String[] { "ETH", "Finney" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,
            items);
    dropdown.setSelection((denomination == Denomination.ETH) ? 0 : 1);
    dropdown.setOnItemSelectedListener(this);
    dropdown.setAdapter(adapter);
    //
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    String app_name = getResources().getString(R.string.app_name);
    toolbar.setTitle(app_name);
    toolbar.setSubtitle("Send Payment");
    toolbar.setBackgroundResource(R.color.color_toolbar);
    setSupportActionBar(toolbar);
    //
    TextView to_addr_view = (TextView) findViewById(R.id.to_addr);
    to_addr_view.setText(to_addr);
    //
    TextView size_view = (TextView) findViewById(R.id.size);
    size_str = (denomination == Denomination.ETH) ? String.format("%1.03f", eth_size)
            : String.format("%03d", (int) (eth_size * 1000 + 0.5));
    size_view.setText(size_str);
    //
    LinearLayout gas_layout = (LinearLayout) findViewById(R.id.gas_layout);
    TextView gas_prompt_view = (TextView) findViewById(R.id.gas_prompt);
    TextView gas_view = (TextView) findViewById(R.id.gas);
    ImageButton gas_help_view = (ImageButton) findViewById(R.id.gas_help);
    if (show_gas) {
        String gas_str = String.format("%7d", gas_limit);
        gas_view.setText(gas_str);
        gas_layout.setVisibility(View.VISIBLE);
        gas_prompt_view.setVisibility(View.VISIBLE);
        gas_help_view.setVisibility(View.VISIBLE);
        gas_view.setVisibility(View.VISIBLE);
    } else {
        gas_layout.setVisibility(View.GONE);
        gas_prompt_view.setVisibility(View.GONE);
        gas_help_view.setVisibility(View.GONE);
        gas_view.setVisibility(View.GONE);
    }

    LinearLayout data_layout = (LinearLayout) findViewById(R.id.data_layout);
    TextView data_prompt_view = (TextView) findViewById(R.id.data_prompt);
    TextView data_view = (TextView) findViewById(R.id.data);
    ImageButton data_help_view = (ImageButton) findViewById(R.id.data_help);
    if (show_data) {
        data_view.setText(data);
        data_layout.setVisibility(View.VISIBLE);
        data_prompt_view.setVisibility(View.VISIBLE);
        data_help_view.setVisibility(View.VISIBLE);
        data_view.setVisibility(View.VISIBLE);
    } else {
        data = "";
        data_layout.setVisibility(View.GONE);
        data_prompt_view.setVisibility(View.GONE);
        data_help_view.setVisibility(View.GONE);
        data_view.setVisibility(View.GONE);
    }

    //
    //sanity check
    if (to_addr.length() != 42) {
        this.finish();
    }
}

From source file:net.yanzm.mth.MaterialTabHost.java

public MaterialTabHost(Context context, AttributeSet attrs) {
    super(context, attrs);

    inflater = LayoutInflater.from(context);

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaterialTabHost, 0, 0);
    int indicatorColor = a.getColor(R.styleable.MaterialTabHost_colorTabIndicator, Color.YELLOW);
    colorControlActivated = a.getColor(R.styleable.MaterialTabHost_colorBackground, Color.WHITE);

    setBackgroundColor(colorControlActivated);
    a.recycle();//  w  w w . j  a  va 2  s  . c o  m

    // ColorDrawable on 2.x does not use getBounds() so use ShapeDrawable
    indicator = new ShapeDrawable();
    indicator.setColorFilter(indicatorColor, PorterDuff.Mode.SRC_ATOP);

    Resources res = context.getResources();
    indicatorHeight = res.getDimensionPixelSize(R.dimen.mth_tab_indicator_height);
    leftOffset = res.getDimensionPixelSize(R.dimen.mth_tab_left_offset);
    int tabHeight = res.getDimensionPixelSize(R.dimen.mth_tab_height);

    tabWidget = new TabWidget(context);
    tabWidget.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, tabHeight));
    tabWidget.setId(android.R.id.tabs);
    tabWidget.setStripEnabled(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        tabWidget.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
    }
    addView(tabWidget);

    FrameLayout fl = new FrameLayout(context);
    fl.setLayoutParams(new LayoutParams(0, 0));
    fl.setId(android.R.id.tabcontent);
    addView(fl);

    setup();

    setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            if (listener != null) {
                listener.onTabSelected(Integer.valueOf(tabId));
            }
        }
    });

    float density = getResources().getDisplayMetrics().density;

    // set elevation for App bar
    // http://www.google.com/design/spec/what-is-material/objects-in-3d-space.html#objects-in-3d-space-elevation
    ViewCompat.setElevation(this, APP_TAB_ELEVATION * density);
}

From source file:com.google.android.apps.iosched.ui.StarredActivity.java

/**
 * Build and add "vendors" tab./* www.  ja va  2s .c  o  m*/
 */
private void setupVendorsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_vendors);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final Intent intent = new Intent(Intent.ACTION_VIEW, Vendors.CONTENT_STARRED_URI);

    final FragmentManager fm = getSupportFragmentManager();

    mVendorsFragment = (VendorsFragment) fm.findFragmentByTag("vendors");
    if (mVendorsFragment == null) {
        mVendorsFragment = new VendorsFragment();
        mVendorsFragment.setArguments(intentToFragmentArguments(intent));
        fm.beginTransaction().add(R.id.fragment_vendors, mVendorsFragment, "vendors").commit();
    }

    // Vendors content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_VENDORS).setIndicator(buildIndicator(R.string.starred_vendors))
            .setContent(R.id.fragment_vendors));
}

From source file:com.github.ppamorim.prismview.PrismActivity.java

/**
 * This check the consistency of the #mainView object and add the #mainView view
 * at the root view, after create a new instance of prismView and add this at the
 * root too./*from  w w  w. ja  v a2  s . co m*/
 * Then, move the #prismView to the right position.
 * @param savedInstanceState
 */
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    if (mainView == null) {
        throw new IllegalStateException("mainView is null, did you set this view?");
    }
    root.addView(mainView);
    if (prismView == null) {
        prismView = new FrameLayout(getApplicationContext());
        prismView.setId(prismView.getClass().hashCode());
    }
    root.addView(prismView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    initializePositions();
}