Example usage for android.widget RelativeLayout RelativeLayout

List of usage examples for android.widget RelativeLayout RelativeLayout

Introduction

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

Prototype

public RelativeLayout(Context context) 

Source Link

Usage

From source file:edu.rowan.app.carousel.CarouselFeature.java

public CarouselFeature(Context context) {
    // default feature with simple default image
    this.context = context;
    imageURL = null;/*from w  w  w.ja v a 2s .co  m*/
    url = null;
    carouselView = new RelativeLayout(context);
    imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.carousel_placeholder);
    carouselView.setTag(DEFAULT_FEATURE_TAG);
    carouselView.addView(imageView);
}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingPlayView.java

/**
 * ???View.//  w  ww  . jav a  2  s  .  c o m
 *
 * @param context the context
 */
public void initView(Context context) {
    this.context = context;
    navLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setOrientation(LinearLayout.VERTICAL);

    RelativeLayout mRelativeLayout = new RelativeLayout(context);

    mViewPager = new AbInnerViewPager(context);
    //ViewPager,fragmentsetId()id
    mViewPager.setId(1985);
    //
    mNavLayoutParent = new LinearLayout(context);
    mNavLayoutParent.setPadding(0, 5, 0, 5);
    navLinearLayout = new LinearLayout(context);
    navLinearLayout.setPadding(15, 1, 15, 1);
    navLinearLayout.setVisibility(View.INVISIBLE);
    mNavLayoutParent.addView(navLinearLayout,
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mRelativeLayout.addView(mViewPager, lp1);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mRelativeLayout.addView(mNavLayoutParent, lp2);
    addView(mRelativeLayout,
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    mListViews = new ArrayList<View>();
    mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews);
    mViewPager.setAdapter(mAbViewPagerAdapter);
    mViewPager.setFadingEdgeLength(0);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            makesurePosition();
            onPageSelectedCallBack(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            onPageScrolledCallBack(position);
        }

    });

}

From source file:com.wms.opensource.ezchannel.activity.VideoListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (layout != null) {
        // We need to remove layout from its parent first. Otherwise, adding layout to different viewgroup will result in error 
        ViewGroup parent = (ViewGroup) layout.getParent();
        parent.removeView(layout);//from   ww  w. j a  v  a 2  s.c om
        return layout;
    }

    if (listView == null) {
        layout = new RelativeLayout(getActivity());
        listView = new ListView(getActivity());
        layout.addView(listView);

        imageViewStandardThumbnail = new ImageView(getActivity());
        RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        imageViewStandardThumbnail.setLayoutParams(imageViewParams);
        imageViewStandardThumbnail.setVisibility(View.INVISIBLE);
        imageViewStandardThumbnail.setBackgroundResource(R.drawable.border);
        imageViewStandardThumbnail.setOnClickListener(new ImageView.OnClickListener() {

            @Override
            public void onClick(View v) {
                // Dismiss the image view
                v.setVisibility(View.INVISIBLE);
                Animation myAnim = AnimationUtils.loadAnimation(VideoListFragment.this.getActivity(),
                        R.anim.fadeout);
                v.startAnimation(myAnim);
            }

        });
        layout.addView(imageViewStandardThumbnail);

        progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge);

        // Center a view in relative layout
        RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT);
        progressBar.setLayoutParams(progressBarBarams);
        progressBar.setVisibility(View.INVISIBLE);
        layout.addView(progressBar);

        // Before reloading videos, display videos if they have been saved before.            
        String videosFilePath = "";
        if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) {
            videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/"
                    + PersistFileNameProvider.getYouTubePlaylistPersistFileName(playlistID, page);
        } else {
            videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameProvider
                    .getYouTubeSearchListPersistFileName(getActivity().getString(R.string.appID), page);
        }

        boolean videosFileExists = FileUtil.fileExist(videosFilePath);
        if (videosFileExists) {
            loadPlaylistVideosFromLocalTask = new LoadCachedVideosTask(getActivity(), loadVideosHandler,
                    VideoListFragmentActivity.videoSource, progressBar, playlistID, page);
            loadPlaylistVideosFromLocalTask.execute();
        } else {
            NetworkStatus networkStatus = NetworkUtil.getNetworkStatus(getActivity());
            if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED)
                    || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) {
                String pageToken = page == 1 ? null : VideoListFragmentActivity.pageTokens.get(page - 1); // page start from 1
                if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) {
                    loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler,
                            YouTubeVideoSource.Playlist, playlistID, pageToken, page);
                } else {
                    loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler,
                            YouTubeVideoSource.Search, queryTerm, pageToken, page);
                }
                loadVideosTask.execute();
            } else {
                Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show();
            }
        }
    }
    return layout;
}

From source file:com.ab.view.sliding.AbSlidingPlayView.java

/**
 * ???View.// w  w w.j  av  a2 s  . c  om
 *
 * @param context the context
 */
public void initView(Context context) {
    this.context = context;
    navLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    RelativeLayout mRelativeLayout = new RelativeLayout(context);

    mViewPager = new AbInnerViewPager(context);
    //ViewPager,fragmentsetId()id
    mViewPager.setId(1985);
    //
    mNavLayoutParent = new LinearLayout(context);
    mNavLayoutParent.setPadding(0, 5, 0, 5);
    navLinearLayout = new LinearLayout(context);
    navLinearLayout.setPadding(15, 1, 15, 1);
    navLinearLayout.setVisibility(View.INVISIBLE);
    mNavLayoutParent.addView(navLinearLayout,
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mRelativeLayout.addView(mViewPager, lp1);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mRelativeLayout.addView(mNavLayoutParent, lp2);
    addView(mRelativeLayout,
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    displayImage = AbFileUtil.getBitmapFromSrc("image/play_display.png");
    hideImage = AbFileUtil.getBitmapFromSrc("image/play_hide.png");

    mListViews = new ArrayList<View>();
    mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews);
    mViewPager.setAdapter(mAbViewPagerAdapter);
    mViewPager.setFadingEdgeLength(0);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            makesurePosition();
            onPageSelectedCallBack(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            onPageScrolledCallBack(position);
        }

    });

}

From source file:com.tony.selene.sliding.AbSlidingPlayView.java

/**
 * ???View.//from w  w w .  j  a v a 2s  .  co  m
 *
 * @param context
 *            the context
 */
public void initView(Context context) {
    this.context = context;
    navLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setOrientation(LinearLayout.VERTICAL);

    RelativeLayout mRelativeLayout = new RelativeLayout(context);

    mViewPager = new AbInnerViewPager(context);
    // ViewPager,fragmentsetId()id
    mViewPager.setId(1985);
    // 
    mNavLayoutParent = new LinearLayout(context);
    mNavLayoutParent.setPadding(0, 5, 0, 5);
    navLinearLayout = new LinearLayout(context);
    navLinearLayout.setPadding(15, 1, 15, 1);
    navLinearLayout.setVisibility(View.INVISIBLE);
    mNavLayoutParent.addView(navLinearLayout,
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mRelativeLayout.addView(mViewPager, lp1);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mRelativeLayout.addView(mNavLayoutParent, lp2);
    addView(mRelativeLayout,
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    mListViews = new ArrayList<View>();
    mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews);
    mViewPager.setAdapter(mAbViewPagerAdapter);
    mViewPager.setFadingEdgeLength(0);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            makesurePosition();
            onPageSelectedCallBack(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            onPageScrolledCallBack(position);
        }

    });

}

From source file:com.wll.main.widget.AbSlidingPlayView.java

/**
 * ???View.//  w w  w.  j  av a  2s.co m
 *
 * @param context
 *            the context
 */
public void initView(Context context) {
    this.context = context;
    navLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    RelativeLayout mRelativeLayout = new RelativeLayout(context);

    mViewPager = new AbInnerViewPager(context);
    // ViewPager,fragmentsetId()id
    mViewPager.setId(getResources().getInteger(R.integer.id_viewPager));
    // 
    mNavLayoutParent = new LinearLayout(context);
    mNavLayoutParent.setPadding(0, 5, 0, 5);
    navLinearLayout = new LinearLayout(context);
    navLinearLayout.setPadding(15, 1, 15, 1);
    navLinearLayout.setVisibility(View.INVISIBLE);
    mNavLayoutParent.addView(navLinearLayout,
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mRelativeLayout.addView(mViewPager, lp1);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mRelativeLayout.addView(mNavLayoutParent, lp2);
    addView(mRelativeLayout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    //      displayImage = AbFileUtil.getBitmapFromSrc("image/play_display.png");
    //      hideImage = AbFileUtil.getBitmapFromSrc("image/play_hide.png");

    Bitmap bm = BitmapFactory.decodeResource(context.getResources(), R.mipmap.d2);
    Bitmap bm2 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.d1);
    displayImage = bm;
    hideImage = bm2;

    mListViews = new ArrayList<View>();
    mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews);
    mViewPager.setAdapter(mAbViewPagerAdapter);
    mViewPager.setFadingEdgeLength(0);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            makesurePosition();
            onPageSelectedCallBack(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            onPageScrolledCallBack(position);
        }

    });

}

From source file:com.xalops.spotifystreamer.fragments.SearchListFragment.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.
 *
 * <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.
 *//*  w  ww .  j  a  va 2s.c  o  m*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    FrameLayout root = new FrameLayout(context);

    //QUICK Inflate from XML file

    //inflater.inflate(R.layout.search_list_detail, root);
    // ------------------------------------------------------------------

    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.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

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

    RelativeLayout rlayout = new RelativeLayout(context);

    EditText et = new EditText(getActivity());
    et.setId(INTERNAL_SEARCH_FIELD_ID);
    et.setSingleLine(true);
    et.setInputType(InputType.TYPE_CLASS_TEXT);
    et.setImeOptions(EditorInfo.IME_ACTION_DONE);
    RelativeLayout.LayoutParams etRLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    RelativeLayout.LayoutParams lframeRLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    lframeRLayoutParams.addRule(RelativeLayout.BELOW, INTERNAL_SEARCH_FIELD_ID);

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

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    rlayout.addView(et, etRLayoutParams);
    rlayout.addView(lframe, lframeRLayoutParams);
    root.addView(rlayout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

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

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

    return root;
}

From source file:com.lxh.util.pullview.AbSlidingPlayView.java

/**
 * ???View./*from  w w w  .  j  av a2s .co m*/
 *
 * @param context
 *            the context
 */
public void initView(Context context) {
    this.context = context;
    navLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setOrientation(LinearLayout.VERTICAL);

    RelativeLayout mRelativeLayout = new RelativeLayout(context);

    mViewPager = new AbInnerViewPager(context);
    // ViewPager,fragmentsetId()id
    mViewPager.setId(1985);
    // 
    mNavLayoutParent = new LinearLayout(context);
    mNavLayoutParent.setPadding(0, 5, 0, 5);
    navLinearLayout = new LinearLayout(context);
    navLinearLayout.setPadding(15, 1, 15, 1);
    navLinearLayout.setVisibility(View.INVISIBLE);
    mNavLayoutParent.addView(navLinearLayout,
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mRelativeLayout.addView(mViewPager, lp1);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mRelativeLayout.addView(mNavLayoutParent, lp2);
    addView(mRelativeLayout,
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    displayImage = FileUtil.getBitmapFromSrc("image/play_display.png");
    hideImage = FileUtil.getBitmapFromSrc("image/play_hide.png");

    mListViews = new ArrayList<View>();
    mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews);
    mViewPager.setAdapter(mAbViewPagerAdapter);
    mViewPager.setFadingEdgeLength(0);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            makesurePosition();
            onPageSelectedCallBack(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            onPageScrolledCallBack(position);
        }

    });

}

From source file:edu.rowan.app.carousel.CarouselFeature.java

public void loadImage() {
    carouselView = new RelativeLayout(context);
    imageView = new ImageView(context);
    Bitmap cachedImage = aq.getCachedImage(imageURL);
    if (cachedImage != null) {
        //         System.out.println("Image was cached!");
        imageView.setImageBitmap(cachedImage);
        carouselView.addView(imageView);
        setupView();//from   w w w .  j  ava 2s . co  m
        listener.doneLoading(this);
    } else {
        // Aquery download and cache image
        aq.id(imageView).image(imageURL, true, true, 0, 0, new BitmapAjaxCallback() {
            @Override
            // set imageview to loaded bitmap and tell listener we're done loading
            public void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) {
                iv.setImageBitmap(bm);
                carouselView.addView(iv);
                setupView();
                listener.doneLoading(CarouselFeature.this);
            }
        });
    }
}

From source file:mobisocial.musubi.ui.FeedIdentityGrid.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //TODO: this begs for being in util, huh.  i wonder where else it is used.
    //check that we aren't going to send a message using the local authority
    //to our friends.  This is similar to the initial hidden state of the 
    //person picker on the feed list
    mDatabaseSource = App.getDatabaseSource(this);
    mIdentitiesManager = new IdentitiesManager(mDatabaseSource);
    mFeedManager = new FeedManager(mDatabaseSource);
    if (mIdentitiesManager.getOwnedIdentities().size() < 2) {
        Toast.makeText(this, "You must connect an account in Musubi to be able to share with your contacts",
                Toast.LENGTH_SHORT).show();
        Intent intent = new Intent(this, FeedListActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);/* w ww  .  j a v  a2  s  . c  om*/
        return;
    }

    setTitle("Share");
    RelativeLayout window = new RelativeLayout(this);
    LayoutParams fill = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    window.setLayoutParams(fill);

    // Identity multi-select
    mIdentitySelector = new MultiIdentitySelector(this);
    mIdentitySelector.setOnIdentitiesUpdatedListener(mIdentitiesUpdatedListener);
    mIdentitySelector.setOnRequestAddIdentityListener(mOnRequestAddIdentityListener);
    RelativeLayout.LayoutParams selectorParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    selectorParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    mIdentitySelector.setLayoutParams(selectorParams);
    mIdentitySelector.setId(R.id.people);

    // Feed list
    mFeedListView = new ListView(this);
    RelativeLayout.LayoutParams listParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT);
    listParams.addRule(RelativeLayout.BELOW, R.id.people);
    listParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    mFeedListView.setLayoutParams(listParams);
    mFeedListView.setOnItemClickListener(mFeedClickListener);
    // Must be called before setAdapter():
    //mFeedListView.addHeaderView(mHeaderView);

    // Bind to content view
    window.addView(mIdentitySelector);
    window.addView(mFeedListView);
    setContentView(window, fill);

    getSupportLoaderManager().initLoader(LOAD_FEEDS, null, this);
}