小编The*_*heQ的帖子

Android - 如何从 s3 下载图像?

我正在阅读 s3 android 指南,并且对如何下载我的文件感到非常困惑。

他们提供以下代码:

TransferObserver observer = transferUtility.download(
  MY_BUCKET,     /* The bucket to download from */
  OBJECT_KEY,    /* The key for the object to download */
  MY_FILE        /* The file to download the object to */
);
Run Code Online (Sandbox Code Playgroud)

那么什么是 MY_FILE?我是否想创建一个本地空文件对象并将其提供给该 transferUtility 下载函数,并将该空文件填充到一次下载中?

而且,当我完成获取文件时,(尤其是图像)我如何使用 glide 或 Picasso 将该文件上传到 imageView 中?

我不确定如何使用 TransferObserver 对象。

希望有人可以提供一个工作示例,请!

干杯!

android amazon-s3 android-imageview picasso

2
推荐指数
1
解决办法
3532
查看次数

如何使dialogFragment宽度与父级匹配?

我有这个dialog fragmentt,我有两个问题.

1.如何使宽度与父母相匹配(最干净,最好的解决方案).

  1. dialog fragment我有一个editText.当对话框片段打开时,如何让它弹出软键盘?

希望你们能帮忙!

这是我的对话框片段java代码:

 @Nullable
    @Override
    public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        rootView  = inflater.inflate(R.layout.activity_13g_add_comment, container, false);//The container is the rootView.

        myCognito = new MyCognito(getActivity().getApplicationContext(),getActivity().getBaseContext());

        cardClient = myCognito.getCardClient();

        bindActivity();

        return rootView;
    }

    private void bindActivity()
    {
        doneButton = (ImageButton) rootView.findViewById(R.id.add_comment_doneButton);
        doneButton.setVisibility(View.GONE);

        imageView = (ImageView) rootView.findViewById(R.id.add_comment_IV);

        RemoveGlideCacheAsyncTask removeGlideCacheAsyncTask = new RemoveGlideCacheAsyncTask(getActivity().getBaseContext(),Global_Class.getInstance().getValue().user.getUsername());
        removeGlideCacheAsyncTask.execute();


        editText = (EditText) rootView.findViewById(R.id.add_comment_ET);

        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) …
Run Code Online (Sandbox Code Playgroud)

xml android android-layout android-xml android-dialogfragment

1
推荐指数
2
解决办法
7299
查看次数

如何更改动作栏切换颜色?-安卓

如何更改操作栏切换按钮的颜色?

在此处输入图片说明

这是我的Java操作栏代码:

  //Navigation view and Drawer layout
        drawerlayout = (DrawerLayout) findViewById(R.id.main_ND);
        actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerlayout,0,0);
        navigationView = (NavigationView) findViewById(R.id.main_NV);
        navigationView.setItemIconTintList(null);
        View headerView = navigationView.getHeaderView(0);
        nD_image = (ImageView) headerView.findViewById(R.id.nd_image);
        Glide.with(getBaseContext()).load(R.drawable.my_paper).centerCrop().into(nD_image);
        setNavigationView();
        drawerlayout.addDrawerListener(actionBarDrawerToggle);
        actionBarDrawerToggle.syncState();
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
}


 @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        if(actionBarDrawerToggle.onOptionsItemSelected(item))
        {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
Run Code Online (Sandbox Code Playgroud)

以我的风格

  <style name="my_theme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimaryDark">@color/salmonDark</item>
        <item name="colorPrimary">@color/salmon_main</item>
        <item name="colorAccent">@color/black</item>
        <item name="android:actionMenuTextColor">@color/white</item><!-- green was: #8BC34A -->
        <item name="android:actionMenuTextAppearance">@style/actionBarTextSize</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

然后在我的清单上

 <activity android:name=".Main.Main"
            android:screenOrientation="portrait"
            android:theme="@style/zivit_theme"/>
Run Code Online (Sandbox Code Playgroud)

我不太确定如何更改颜色或在哪里进行更改。我希望有人可以张贴一些分步过程的示例代码(或执行此操作的那神奇的一行代码),谢谢!

android android-layout android-xml android-actionbar android-styles

0
推荐指数
1
解决办法
2070
查看次数

将recyclerview的焦点更改为某些项目的位置?

So I have a standard RecyclerView that takes a list of posts and displays them to the user. My problem is when the user comes into the activity, I want to be able to change the focus to a particular post.

Ex. User A sees that he has a notification that of someone has liked his/her post. He/she clicks that notification, and it loads the activity of user's post, and then the focus changes to the position of the post …

android android-layout android-studio android-recyclerview

-1
推荐指数
1
解决办法
1万
查看次数