LocationManagerAndroid上的API似乎对于仅需要偶尔粗略估计用户位置的应用程序来说有点痛苦.
我正在处理的应用程序本身并不是一个位置应用程序,但它确实需要获取用户的位置才能显示附近的商家列表.它不需要担心用户是否在移动或类似的东西.
这是我想做的事情:
ActivityX中需要它时,它将可用.看起来它应该不那么难,但在我看来,我必须启动两个不同的位置提供商(GPS和NETWORK)并管理每个生命周期.不仅如此,我还必须在多个活动中复制相同的代码以满足#2.我曾尝试过使用getBestProvider()过去将解决方案缩减为只使用一个位置提供商,但这似乎只能为您提供最好的"理论"提供商,而不是实际上会给您带来最佳结果的提供商.
有没有更简单的方法来实现这一目标?
是否有一个内置于Java中的函数可以将String中每个单词的第一个字符大写,而不影响其他单词?
例子:
jon skeet - > Jon Skeetmiles o'Brien- > Miles O'Brien(B仍然是资本,这排除了标题案例)old mcdonald- > Old Mcdonald**(Old McDonald也会发现,但我不认为它那么聪明.)
就让我们来看看在Java的String文档仅揭示toUpperCase()和toLowerCase(),这当然不提供所需的行为.当然,谷歌的结果由这两个功能主导.它看起来像一个必须已经发明的轮子,所以它可以不会受到伤害,所以我可以在将来使用它.
我有" Android是一个软件堆栈 " 的文字.在本文中,我想设置" 堆栈 "文本是可点击的.从某种意义上说,如果你点击它,它将被重定向到一个新的活动(而不是在浏览器中).
我试过但我没有得到.
我已将我的SDK更新为API 21,现在后退/上移图标是指向左侧的黑色箭头.

我希望它是灰色的.我怎样才能做到这一点?
例如,在Play商店中,箭头为白色.
我这样做是为了设置一些风格.我已经习惯@drawable/abc_ic_ab_back_mtrl_am_alpha了homeAsUpIndicator.drawable是透明的(只有alpha),但箭头显示为黑色.我想知道我是否能像我一样设置颜色DrawerArrowStyle.或者,如果唯一的解决方案是创建我的@drawable/grey_arrow并使用它homeAsUpIndicator.
<!-- Base application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle" tools:ignore="NewApi">@style/MyActionBar</item>
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>
<item name="android:homeAsUpIndicator" tools:ignore="NewApi">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>
</style>
<!-- ActionBar style -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:background">@color/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">@color/actionbar_background</item>
</style>
<!-- Style for the navigation drawer icon -->
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@color/actionbar_text</item>
</style>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我的解决方案是采用@drawable/abc_ic_ab_back_mtrl_am_alpha看似白色的,并使用照片编辑器将其绘制成我想要的颜色.它的工作原理,但我更喜欢使用@color/actionbar_text像DrawerArrowStyle.
在我的活动中,我创建了一个Bitmap对象,然后我需要启动另一个Activity,如何Bitmap从子活动(将要启动的那个)传递这个对象?
我有一个带有TextView文本框和十字按钮ImageView的RecyclerView.我在recyclerview外面有一个按钮,使十字按钮ImageView可见/消失.
我正在寻找从recylerview中删除项目,当按下该项目交叉按钮ImageView时.
我的适配器:
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> implements View.OnClickListener, View.OnLongClickListener {
private ArrayList<String> mDataset;
private static Context sContext;
public MyAdapter(Context context, ArrayList<String> myDataset) {
mDataset = myDataset;
sContext = context;
}
@Override
public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_text_view, parent, false);
ViewHolder holder = new ViewHolder(v);
holder.mNameTextView.setOnClickListener(MyAdapter.this);
holder.mNameTextView.setOnLongClickListener(MyAdapter.this);
holder.mNameTextView.setTag(holder);
return holder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.mNameTextView.setText(mDataset.get(position));
}
@Override
public int getItemCount() {
return mDataset.size();
}
@Override
public void onClick(View view) { …Run Code Online (Sandbox Code Playgroud) 我有一个RecyclerView和一个活动ImageView.我正在使用它RecyclerView来水平显示图像列表.当我在点击图片RecyclerView将ImageView在活动中应显示图像的大局观.到目前为止一切正常.
现在活动还有两个ImageButtons:imageButton_left和imageButton_right.当我点击时imageButton_left,该图像ImageView应向左转,并且该缩略图RecyclerView应反映此更改.情况类似imageButton_right.
我能够旋转ImageView.但是,我怎么能旋转缩略图RecyclerView?我如何获得ViewHolder的ImageView?
码:
活动XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
<ImageView
android:id="@+id/original_image"
android:layout_width="200dp"
android:layout_height="200dp"
android:scaleType="fitXY"
android:src="@drawable/image_not_available_2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ImageButton
android:id="@+id/imageButton_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:background="@drawable/rotate_left_icon" />
<ImageButton
android:id="@+id/imageButton_right"
android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我正在尝试将URI-Object传递给我的Intent,以便在另一个活动中使用该URI ...
如何传递URI?
private Uri imageUri;
....
Intent intent = new Intent(this, GoogleActivity.class);
intent.putExtra("imageUri", imageUri);
startActivity(intent);
this.finish();
Run Code Online (Sandbox Code Playgroud)
如何在我的其他活动中使用此URI?
imageUri = extras.getString("imageUri"); // I know thats wrong ...
Run Code Online (Sandbox Code Playgroud)
感谢你们
我正在关注这个例子
http://www.androidhive.info/2015/04/android-getting-started-with-material-design/
在这个例子中它显示白色汉堡图标,我想自定义它并使其变黑,但我无法找到任何如何更改它,任何人都可以告诉如何自定义它?
表现
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.androidhive.materialdesign" >
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyMaterialTheme" >
<activity
android:name=".activity.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
样式
<resources>
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="homeAsUpIndicator">@drawable/hamburger</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
主要活动
public class MainActivity extends AppCompatActivity implements FragmentDrawer.FragmentDrawerListener {
private static String TAG = MainActivity.class.getSimpleName();
private Toolbar mToolbar;
private FragmentDrawer drawerFragment;
@Override
protected void …Run Code Online (Sandbox Code Playgroud) java user-interface android navigation-drawer material-design
我已经实现了一个RecyclerView,主要包含通过Picasso加载的图像.我的问题是,只要我向下或向上滚动视图,占位符图像就会显示约.在它被实际图像替换之前的一秒钟.它滚动非常顺利,但几乎无法使用.每次滚动屏幕时都会发生这种情况.
Picasso显然将图像缓存到磁盘,因为它们的加载速度比初始加载时间快,但它们肯定会立即从缓存中重新加载.我做错了什么?
我的适配器代码:
public class ExploreAdapter extends RecyclerView.Adapter<ExploreAdapter.ExploreViewHolder> {
private List<ExploreItem> exploreItemList;
private Context mContext;
private int deviceWidth = PrefUtils.getDeviceWidth();
public ExploreAdapter(Context context, List<ExploreItem> exploreItemList){
this.mContext = context;
this.exploreItemList = exploreItemList;
}
@Override
public int getItemCount(){
return exploreItemList.size();
}
@Override
public void onBindViewHolder(ExploreViewHolder exploreViewHolder, int i){
ExploreItem item = exploreItemList.get(i);
exploreViewHolder.getvTitle().setText(item.getTitle());
exploreViewHolder.getvUsername().setText(item.getUsername());
exploreViewHolder.getvNumLikes().setText(item.getNbOfLikes());
Picasso.with(mContext).load(item.getMediaLocation().trim())
.resize(deviceWidth, deviceWidth)
.centerCrop()
.placeholder(R.drawable.profile_background)
.into(exploreViewHolder.getvImage());
Picasso.with(mContext).load(item.getUserProfilePicUrl().trim())
.placeholder(R.drawable.profile_picture)
.into(exploreViewHolder.getvProfilePic());
}
@Override
public ExploreViewHolder onCreateViewHolder(ViewGroup viewGroup, int i){
View itemView = LayoutInflater.
from(viewGroup.getContext()).
inflate(R.layout.explore_item, viewGroup, false);
return new …Run Code Online (Sandbox Code Playgroud) java android picasso android-5.0-lollipop android-recyclerview