Example usage for android.widget ImageView setPadding

List of usage examples for android.widget ImageView setPadding

Introduction

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

Prototype

public void setPadding(int left, int top, int right, int bottom) 

Source Link

Document

Sets the padding.

Usage

From source file:com.lurencun.cfuture09.androidkit.uilibs.IntroActivity.java

/**
 * //from  ww  w  .ja v  a  2s.c  o  m
 */
private void createContentView() {
    // ?
    mIntroResource = new IntroResource();
    setIntroViews(mIntroResource);

    // 
    RelativeLayout rootView = new RelativeLayout(this);
    rootView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    // 
    mViewPager = new ViewPager(this);
    RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
    rootView.addView(mViewPager, pagerParams);

    // 
    LinearLayout indicatorLayout = new LinearLayout(this);
    RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom;
    indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    indicatorLayout.setLayoutParams(indicatorParams);
    indicatorLayout.setOrientation(LinearLayout.HORIZONTAL);

    // 
    int indicatorCount = mIntroResource.views.size();
    int padding = mIntroResource.indicatorImagePadding;
    mIndicator = new ArrayList<ImageView>();
    for (int i = 0; i < indicatorCount; i++) {
        ImageView imageView = new ImageView(this);
        LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        imageView.setPadding(padding, padding, padding, padding);
        imageView.setClickable(true);
        imageView.setOnClickListener(this);
        imageView.setImageResource(mIntroResource.indicatorNoSelectedId);
        imageView.setTag(i);
        mIndicator.add(imageView);
        indicatorLayout.addView(imageView, imageParams);
    }

    rootView.addView(indicatorLayout);

    setContentView(rootView);
}

From source file:com.landenlabs.all_devtool.IconBaseFragment.java

/**
 * Show a 'LayerDrawable'  information./*from   w w  w . j a v  a 2 s  .  c  o  m*/
 *
 * @param imageView
 * @param row1
 * @param row2
 * @param iconD
 * @param layerIdx
 */
private void showLayerIcon(final ImageView imageView, TableRow row1, TableRow row2, Drawable iconD,
        int layerIdx) {

    if (iconD != null) {
        ImageView layerImageView = new ImageView(imageView.getContext());

        layerImageView.setImageDrawable(iconD);
        layerImageView.setPadding(10, 10, 10, 10);
        layerImageView.setMinimumHeight(8);
        layerImageView.setMinimumWidth(8);
        layerImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageView.setImageDrawable(((ImageView) v).getDrawable());
            }
        });

        TextView stateTextView = new TextView(imageView.getContext());
        stateTextView.setText(String.valueOf(layerIdx));
        stateTextView.setTextSize(12);
        stateTextView.setGravity(Gravity.CENTER);

        row1.addView(stateTextView);
        row2.addView(layerImageView);
    }
}

From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.AmharicKeyboardView.java

private void populateKeyboardRow(KeyboardRow keyboardRow, int keyHeight) {
    Context context = getContext();
    LinearLayout keyContainer = new LinearLayout(context);
    keyContainer.setOrientation(HORIZONTAL);
    keyContainer.setGravity(Gravity.CENTER);

    List<KeyboardKey> keyList = keyboardRow.getKeyList();
    if (keyList != null) {
        for (int i = 0; i < keyList.size(); i++) {
            KeyboardKey keyboardKey = keyList.get(i);
            if (keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_NORMAL) {
                TextView key = new TextView(context);
                key.setGravity(Gravity.CENTER);
                key.setTypeface(mCharTypeface, Typeface.BOLD);
                key.setText(keyboardKey.getCharCode());
                key.setTextSize(16f);//w  w w .  j  a  v  a2s  .  c om
                key.setTextColor(
                        ContextCompat.getColorStateList(context, R.color.amharic_key_text_color_selector));
                key.setTag(keyboardKey);
                key.setIncludeFontPadding(false);
                keyContainer.setBaselineAligned(false);
                handleChild(key, keyboardKey.getColumnCount(), keyContainer, keyHeight);
            } else if (keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_BACKSPACE
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_SPACE
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_NEW_LINE
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_ENTER
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_HIDE_KEYBOARD) {
                ImageView child = new ImageView(context);
                child.setImageResource(keyboardKey.getCommandImage());
                int padding = getCustomSize(6);
                child.setPadding(padding, padding, padding, padding);
                child.setTag(keyboardKey);
                handleChild(child, keyboardKey.getColumnCount(), keyContainer, keyHeight);
            }
        }
    }
    addView(keyContainer, new LayoutParams(LayoutParams.MATCH_PARENT, keyHeight));
}

From source file:org.zywx.wbpalmstar.plugin.uexPopoverMenu.EUExPopoverMenu.java

private void showPopoverMenu(double x, double y, int direction, String bgColorStr, String dividerColor,
        String textColor, int textSize, JSONArray data) {
    LinearLayout rootView = (LinearLayout) LayoutInflater.from(mContext)
            .inflate(finder.getLayoutId("plugin_uex_popovermenu"), null);

    final PopupWindow popupWindow = new PopupWindow(rootView, LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, true);

    popupWindow.setContentView(rootView);
    ///*from  www .j av  a  2s . c o m*/
    rootView.setBackgroundColor(Color.parseColor(bgColorStr));
    popupWindow.setContentView(rootView);
    //popupWindow?
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setOutsideTouchable(true);

    int length = data.length();
    List<ItemData> itemDataList = new ArrayList<ItemData>();
    try {
        for (int i = 0; i < length; i++) {
            ItemData item = new ItemData();
            String icon = data.getJSONObject(i).optString("icon", "");
            if (!hasIcon && !TextUtils.isEmpty(icon)) {
                hasIcon = true;
            }
            if (hasIcon) {
                item.setIcon(data.getJSONObject(i).getString("icon"));
            }
            item.setText(data.getJSONObject(i).getString("text"));
            itemDataList.add(item);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < length; i++) {
        LinearLayout linearLayout = new LinearLayout(mContext);
        linearLayout.setOrientation(LinearLayout.HORIZONTAL);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));

        if (hasIcon) {
            ImageView imageView = new ImageView(mContext);
            imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            String imagePath = itemDataList.get(i).getIcon();
            imageView.setImageBitmap(getBitmapFromPath(imagePath));
            imageView.setPadding(DensityUtil.dip2px(mContext, 5), 0, 0, 0);
            linearLayout.addView(imageView);
        }
        TextView tvText = new TextView(mContext);
        LinearLayout.LayoutParams tvLayoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        tvLayoutParams.gravity = Gravity.CENTER_VERTICAL;
        tvText.setLayoutParams(tvLayoutParams);

        tvText.setPadding(DensityUtil.dip2px(mContext, 5), 0, DensityUtil.dip2px(mContext, 8), 0);
        tvText.setText(itemDataList.get(i).getText());
        tvText.setTextColor(Color.parseColor(textColor));
        tvText.setTextSize(textSize);
        linearLayout.addView(tvText);
        linearLayout.setTag(i);
        linearLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                callBackPluginJs(CALLBACK_ITEM_SELECTED, String.valueOf(v.getTag()));
                if (popupWindow != null && popupWindow.isShowing()) {
                    popupWindow.dismiss();
                }
            }
        });
        rootView.addView(linearLayout);

        //
        View dividerLine = new View(mContext);
        dividerLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                DensityUtil.dip2px(mContext, 1)));
        dividerLine.setBackgroundColor(Color.parseColor(dividerColor));
        rootView.addView(dividerLine);
    }
    int gravityParam;
    switch (direction) {
    case 0:
        gravityParam = Gravity.LEFT | Gravity.TOP;
        break;
    case 1:
        gravityParam = Gravity.RIGHT | Gravity.TOP;
        break;
    case 2:
        gravityParam = Gravity.LEFT | Gravity.BOTTOM;
        break;
    case 3:
        gravityParam = Gravity.RIGHT | Gravity.BOTTOM;
        break;
    default:
        gravityParam = Gravity.LEFT | Gravity.TOP;
        break;
    }
    popupWindow.showAtLocation(mBrwView.getRootView(), gravityParam, (int) x, (int) y);
}

From source file:com.yojiokisoft.yumekanow.activity.MakeCardActivity.java

/**
 * ???/*from w  w  w  . ja va 2s.  com*/
 * 
 * @param list
 */
private void setBackImageList(List<BackImageEntity> list) {
    int cnt = mBackImgContainer.getChildCount();
    if (cnt > 0) {
        mBackImgContainer.removeAllViews();
    }
    int w = MyResource.dip2Px(53);
    int h = MyResource.dip2Px(80);
    int p = MyResource.dip2Px(3);
    int size = list.size();
    for (int i = 0; i < size; i++) {
        ImageView image = new ImageView(this);
        MyImage.setImageThum(image, list.get(i));
        image.setLayoutParams(new LinearLayout.LayoutParams(w, h));
        image.setPadding(p, p, p, p);
        image.setTag(i);
        image.setOnClickListener(mBackImageClicked);
        mBackImgContainer.addView(image);
    }
}

From source file:net.naonedbus.fragment.impl.ItineraireFragment.java

private void setIcon(final ImageView imageView, final int icoRes, final int color) {
    imageView.setImageResource(icoRes);/*from   w  ww.  j a  va2 s.  c o m*/
    if (color == Color.TRANSPARENT) {
        imageView.setBackgroundDrawable(null);
        imageView.setPadding(0, 0, 0, 0);
    } else {
        imageView.setBackgroundDrawable(ColorUtils.getCircle(color));
        imageView.setPadding(mIconPadding, mIconPadding, mIconPadding, mIconPadding);
    }
}

From source file:br.org.funcate.dynamicforms.views.GPictureView.java

private ImageView getImageView(final Context context, Bitmap photo, String uuid) {
    ImageView imageView = new ImageView(context);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(thumbnailWidth, thumbnailHeight));
    imageView.setPadding(5, 5, 5, 5);
    imageView.setImageBitmap(photo);// w  w  w .  j a v  a  2s  . c om
    imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.border_black_1px));
    imageView.setTag(uuid);
    imageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String photoId = (String) v.getTag();

            FragmentActivity activity = mFragmentDetail.getActivity();
            Intent intent = new Intent(activity, PictureActivity.class);

            if (addedIdsToImageViews.containsKey(photoId)) {// pictures on session
                intent.putExtra(FormUtilities.PICTURE_PATH_VIEW, addedIdsToImageViews.get(photoId));
            } else if (_pictures.containsKey(photoId)) {// pictures from database

                Map<String, String> imagePaths = _pictures.get(photoId);
                String imagePath = imagePaths.get("display");

                intent.putExtra(FormUtilities.PICTURE_DB_VIEW, imagePath);// Image temporary path
            }
            if (intent.hasExtra(FormUtilities.PICTURE_PATH_VIEW)
                    || intent.hasExtra(FormUtilities.PICTURE_DB_VIEW)) {
                intent.putExtra(FormUtilities.PICTURE_BITMAP_ID, photoId);
                activity.startActivityForResult(intent, PICTURE_VIEW_RESULT);
            } else
                Toast.makeText(getContext(), "Fail, the picture not found.", Toast.LENGTH_LONG).show();

            /*
            JSONArray form = null;
            try {
            form = mFragmentDetail.getSelectedForm();
            } catch (JSONException jse) {
            jse.printStackTrace();
            Toast.makeText(getContext(), jse.getMessage(), Toast.LENGTH_LONG).show();
            }
                    
            if (form != null) {
            try {
                String json = encodeToJson();
                FormUtilities.updatePicture(form, json);
            } catch (JSONException e) {
                e.printStackTrace();
            }catch (Exception e) {
                e.printStackTrace();
            }
            }
            try {
            refresh(getContext());
            } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
            }*/
            /**
             * open in markers to edit it
             */
            // MarkersUtilities.launchOnImage(context, image);
            /* try {
                 Intent intent = new Intent();
                 intent.setAction(Intent.ACTION_VIEW);
                 Image image = imagesDbHelper.getImage(imageIdLong);
                 File tempDir = ResourcesManager.getInstance(context).getTempDir();
                 String ext = ".jpg";
                 if (image.getName().endsWith(".png"))
                     ext = ".png";
                 File imageFile = new File(tempDir, ImageUtilities.getTempImageName(ext));
                 byte[] imageData = imagesDbHelper.getImageData(image.getId());
                 ImageUtilities.writeImageDataToFile(imageData, imageFile.getAbsolutePath());
                    
                 intent.setDataAndType(Uri.fromFile(imageFile), "image*//**//*"); //$NON-NLS-1$
                                                                             context.startActivity(intent);
                                                                             } catch (Exception e) {
                                                                             //GPLog.error(this, null, e);
                                                                             Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
                                                                             }*/
            //Toast.makeText(getContext(), "Implement this action", Toast.LENGTH_LONG).show();

        }
    });
    return imageView;
}

From source file:de.geeksfactory.opacclient.frontend.ResultsAdapter.java

@Override
public View getView(int position, View contentView, ViewGroup viewGroup) {
    View view;/*from   w  w w  .  j ava  2s .c om*/

    // position always 0-7
    if (objects.get(position) == null) {
        LayoutInflater layoutInflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false);
        return view;
    }

    SearchResult item = objects.get(position);

    if (contentView == null) {
        LayoutInflater layoutInflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false);
    } else {
        view = contentView;
    }

    TextView tv = (TextView) view.findViewById(R.id.tvResult);
    tv.setText(Html.fromHtml(item.getInnerhtml()));

    ImageView ivType = (ImageView) view.findViewById(R.id.ivType);

    PreferenceDataSource pds = new PreferenceDataSource(getContext());
    ConnectivityManager connMgr = (ConnectivityManager) getContext()
            .getSystemService(Context.CONNECTIVITY_SERVICE);

    if (item.getCoverBitmap() != null) {
        ivType.setImageBitmap(BitmapUtils.bitmapFromBytes(item.getCoverBitmap()));
        ivType.setVisibility(View.VISIBLE);
        ivType.setPadding(0, 0, 0, 0);
    } else if ((pds.isLoadCoversOnDataPreferenceSet()
            || !ConnectivityManagerCompat.isActiveNetworkMetered(connMgr)) && item.getCover() != null) {
        LoadCoverTask lct = new LoadCoverTask(ivType, item);
        lct.execute();
        ivType.setImageResource(R.drawable.ic_loading);
        ivType.setVisibility(View.VISIBLE);
        ivType.setPadding(0, 0, 0, 0);
    } else if (item.getType() != null && item.getType() != MediaType.NONE) {
        ivType.setImageResource(getResourceByMediaType(item.getType()));
        ivType.setVisibility(View.VISIBLE);
        ivType.setPadding(padding8dp, padding8dp, padding8dp, padding8dp);
    } else {
        ivType.setVisibility(View.INVISIBLE);
    }
    ImageView ivStatus = (ImageView) view.findViewById(R.id.ivStatus);

    if (item.getStatus() != null) {
        ivStatus.setVisibility(View.VISIBLE);
        switch (item.getStatus()) {
        case GREEN:
            ivStatus.setImageResource(R.drawable.status_light_green_check);
            break;
        case RED:
            ivStatus.setImageResource(R.drawable.status_light_red_cross);
            break;
        case YELLOW:
            ivStatus.setImageResource(R.drawable.status_light_yellow_alert);
            break;
        case UNKNOWN:
            ivStatus.setVisibility(View.INVISIBLE);
            break;
        }
    } else {
        ivStatus.setVisibility(View.GONE);
    }

    return view;
}

From source file:paulscode.android.mupen64plusae.SplashActivity.java

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

    // Get app data and user preferences
    mAppData = new AppData(this);
    mGlobalPrefs = new GlobalPrefs(this, mAppData);
    mGlobalPrefs.enforceLocale(this);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);

    // Ensure that any missing preferences are populated with defaults (e.g. preference added to
    // new release)
    PreferenceManager.setDefaultValues(this, R.xml.preferences_audio, false);
    PreferenceManager.setDefaultValues(this, R.xml.preferences_data, false);
    PreferenceManager.setDefaultValues(this, R.xml.preferences_display, false);
    PreferenceManager.setDefaultValues(this, R.xml.preferences_input, false);
    PreferenceManager.setDefaultValues(this, R.xml.preferences_library, false);
    PreferenceManager.setDefaultValues(this, R.xml.preferences_touchscreen, false);

    // Ensure that selected plugin names and other list preferences are valid
    // @formatter:off
    final Resources res = getResources();
    PrefUtil.validateListPreference(res, mPrefs, DISPLAY_ORIENTATION, R.string.displayOrientation_default,
            R.array.displayOrientation_values);
    PrefUtil.validateListPreference(res, mPrefs, DISPLAY_POSITION, R.string.displayPosition_default,
            R.array.displayPosition_values);
    PrefUtil.validateListPreference(res, mPrefs, DISPLAY_SCALING, R.string.displayScaling_default,
            R.array.displayScaling_values);
    PrefUtil.validateListPreference(res, mPrefs, VIDEO_HARDWARE_TYPE, R.string.videoHardwareType_default,
            R.array.videoHardwareType_values);
    PrefUtil.validateListPreference(res, mPrefs, AUDIO_PLUGIN, R.string.audioPlugin_default,
            R.array.audioPlugin_values);
    PrefUtil.validateListPreference(res, mPrefs, AUDIO_SDL_BUFFER_SIZE, R.string.audioSDLBufferSize_default,
            R.array.audioSDLBufferSize_values);
    PrefUtil.validateListPreference(res, mPrefs, AUDIO_SLES_BUFFER_SIZE, R.string.audioSLESBufferSize_default,
            R.array.audioSLESBufferSize_values);
    PrefUtil.validateListPreference(res, mPrefs, TOUCHSCREEN_AUTO_HOLD, R.string.touchscreenAutoHold_default,
            R.array.touchscreenAutoHold_values);
    PrefUtil.validateListPreference(res, mPrefs, NAVIGATION_MODE, R.string.navigationMode_default,
            R.array.navigationMode_values);

    if (!mPrefs.getBoolean("seen_survey", false)) {
        LinearLayout dialogLayout = new LinearLayout(this);
        dialogLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        dialogLayout.setOrientation(LinearLayout.VERTICAL);
        TextView message = new TextView(this);
        message.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        message.setText("We have recently changed our icon and we want your feedback!\n\n"
                + "Please take a few moments to fill out this feedback form so we can make improvements. "
                + "You will need a Google account to fill out this form. This is so we don't have duplicates.");
        message.setPadding(16, 16, 16, 16);
        dialogLayout.addView(message);//from w w  w  .ja v  a2  s. c  om
        ImageView icon = new ImageView(this);
        icon.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        icon.setAdjustViewBounds(true);
        icon.setPadding(16, 16, 16, 16);
        icon.setImageResource(R.drawable.ic_playstore_ouya);
        dialogLayout.addView(icon);
        AlertDialog dialog = new AlertDialog.Builder().setTitle("We want your feedback!").setView(iconLayout)
                .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(
                                "https://docs.google.com/forms/d/1F2stkHvb0Rx5vfmaz50OtTfT73XjHK2GEXZj9a_x-yw/viewform"));
                        SplashActivity.this.startActivity(i);
                    }
                }).setNegativeButton(getString(android.R.string.cancel), null).create();
        mPrefs.edit().putBoolean("seen_survey", true).apply();
        dialog.show();
    }
    //Check for invalid data path
    String dataPathString = mPrefs.getString(DATA_PATH, null);

    if (dataPathString == null || dataPathString.isEmpty()
            || dataPathString.contains(res.getString(R.string.pathGameSaves_default))) {
        String defValue = res.getString(R.string.pathGameSaves_default);
        String newDefValue = PathPreference.validate(defValue);

        mPrefs.edit().putString(DATA_PATH, newDefValue).commit();
    }

    // @formatter:on

    // Refresh the preference data wrapper
    mGlobalPrefs = new GlobalPrefs(this, mAppData);

    // Make sure custom skin directory exist
    new File(mGlobalPrefs.touchscreenCustomSkinsDir).mkdirs();

    // Initialize the OUYA interface if running on OUYA
    if (AppData.IS_OUYA_HARDWARE)
        OuyaFacade.getInstance().init(this, DEVELOPER_ID);

    // Initialize the toast/status bar notifier
    Notifier.initialize(this);

    // Don't let the activity sleep in the middle of extraction
    getWindow().setFlags(LayoutParams.FLAG_KEEP_SCREEN_ON, LayoutParams.FLAG_KEEP_SCREEN_ON);

    // Lay out the content
    setContentView(R.layout.splash_activity);
    mTextView = (TextView) findViewById(R.id.mainText);

    if (mGlobalPrefs.isBigScreenMode) {
        final ImageView splash = (ImageView) findViewById(R.id.mainImage);
        splash.setImageResource(R.drawable.publisherlogo_ouya);
    }

    requestPermissions();

    // Popup a warning if the installation appears to be corrupt
    if (!mAppData.isValidInstallation()) {
        Popups.showInvalidInstall(this);
    }
}

From source file:com.joravasal.comicagg.ComicDetailFragment.java

@SuppressLint({ "NewApi" })
@Override/*from w  w w  .jav a 2 s .  c om*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_comic_detail, container, false);
    if (comicItem == null && savedInstanceState.containsKey(ARG_ITEM_ID)) {
        comicItem = new ComicItem(savedInstanceState.getString(ARG_ITEM_ID),
                savedInstanceState.getString("comicname"), savedInstanceState.getString("comicurl"),
                savedInstanceState.getString("unreadcount"));
    }
    int unread = Integer.parseInt(comicItem.unreadCount);
    if (unread == 0) {
        rootView.findViewById(R.id.vote_bar).setVisibility(View.GONE);
    }
    LinearLayout stripList = (LinearLayout) rootView.findViewById(R.id.strips_list);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    if (comicItem.id.equals(ComicStripsContent.id) && ComicStripsContent.ITEMS.size() > unread) {
        unread = ComicStripsContent.ITEMS.size();
    }
    for (int i = 1; i < unread; i++) {
        ImageView iv = new ImageView(getActivity());
        iv.setId(Integer.MAX_VALUE - i);
        iv.setPadding(16, 16, 16, 0);
        iv.setContentDescription(getString(R.string.strip_description));
        iv.setAdjustViewBounds(true);

        iv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO check if there is need of opening? or always open?
                openFullscreenStrip(v);
            }
        });

        TextView tv = new TextView(getActivity());
        tv.setId(i);
        tv.setPadding(16, 4, 16, 4);
        tv.setGravity(Gravity.CENTER);

        stripList.addView(iv, layoutParams);
        stripList.addView(tv, layoutParams);
    }

    if (!comicItem.id.equals(ComicStripsContent.id)) {
        new GetComicsStrips(comicItem.id, unread, rootView).execute();
    } else {
        new GetComicsStrips(comicItem.id, unread, rootView).onPostExecute(null);
    }
    if (savedInstanceState != null && savedInstanceState.containsKey(VERTICAL_SCROLLING_POSITION)
            && VERSION.SDK_INT >= 14) {
        rootView.findViewById(R.id.comic_scrollView).scrollTo(0,
                savedInstanceState.getInt(VERTICAL_SCROLLING_POSITION));
    }
    return rootView;
}