我有一个GPS应用程序已经ACCESS_FINE_LOCATION在清单中请求权限,现在我想添加一个需要的库(MoPub)ACCESS_COARSE_LOCATION.
假设这ACCESS_FINE_LOCATION已经足够我是否正确,我可以ACCESS_COARSE_LOCATION从我的清单中遗漏?
我上课时遇到了麻烦Parcelable.麻烦的是,我正在尝试写一个包中的一个成员作为一个ArrayList<Parcelable>对象.的ArrayList是Serializable,和对象(ZigBeeDev)在列表中的Parcelable.
这是相关代码:
package com.gnychis.coexisyst;
import java.util.ArrayList;
import java.util.Iterator;
import android.os.Parcel;
import android.os.Parcelable;
public class ZigBeeNetwork implements Parcelable {
public String _mac; // the source address (of the coordinator?)
public String _pan; // the network address
public int _band; // the channel
ArrayList<Integer> _lqis; // link quality indicators (to all devices?)
ArrayList<ZigBeeDev> _devices; // the devices in the network
public void writeToParcel(Parcel out, int flags) {
out.writeString(_mac);
out.writeString(_pan);
out.writeInt(_band); …Run Code Online (Sandbox Code Playgroud) 我试图在增加最后一个元件行下面的间距RecyclerView有GridLayoutManager.ItemDecoration为了这个目的,我使用自定义底部填充,当它的最后一个元素如下:
public class SpaceItemDecoration extends RecyclerView.ItemDecoration {
private int space;
private int bottomSpace = 0;
public SpaceItemDecoration(int space, int bottomSpace) {
this.space = space;
this.bottomSpace = bottomSpace;
}
public SpaceItemDecoration(int space) {
this.space = space;
this.bottomSpace = 0;
}
@Override
public void getItemOffsets(Rect outRect, View view,
RecyclerView parent, RecyclerView.State state) {
int childCount = parent.getChildCount();
final int itemPosition = parent.getChildAdapterPosition(view);
final int itemCount = state.getItemCount();
outRect.left = space;
outRect.right = space;
outRect.bottom = space; …Run Code Online (Sandbox Code Playgroud) 所以我的布局看起来基本上像这样:
<ScrollView>
<RelativeLayout>
<BunchOfViews/>
<ImageView android:layout_alignParentBottom="true"/>
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我有,ScrollView所以无论屏幕高度如何,所有布局始终都是可见的.问题是在非常高的屏幕上,我仍然希望我ImageView处于最底层.然而,一个孩子ScrollView似乎没有明确的底部.在View被放置在布局的顶部.如何以一种简洁的方式解决这个问题?
使用最后一个android.support.v7.widget.Toolbar我想在工具栏中居中一个图像,但它一直停留在左边.
对我来说最好的方法是使用toolbar.setLogo()方法并使徽标居中,但我看不到任何方法.
我使用的布局Toolbar:
<android.support.v7.widget.Toolbar style="@style/ToolBarStyle"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="@dimen/abc_action_bar_default_height_material">
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
是否有可能在工具栏中添加图像(徽标)并使其居中?以编程方式或在布局中?
有谁知道如何在调试期间查看游标中的内容,以便我可以确定数据库帮助程序的功能?
它一直表现得像是在返回数据,但是当我尝试使用该cursor.isNull(0)方法时,我不断被NullPointerException抛出而无法看到光标在其中的内容,而单步执行则让我非常沮丧.
任何帮助将非常感激.
谢谢.
我在其中有一个片段RecyclerView与LinearLayoutManager其中有CardView项目.点击时有一个浮动操作按钮,项目应滚动到顶部.我已经尝试使用scrollToPosition以及scrollToPositionWithOffset与RecyclerView和也LinearLayoutManager,如下图所示.但它根本没有效果.为什么会这样?任何人都可以帮助我.
我已将其RecyclerView直接放在SwipeRefreshViewxml文件中.我setFloatingActionButton一旦设置适配器就打电话给我RecyclerView.
public void setFloatingActionButton(final View view) {
float = (android.support.design.widget.FloatingActionButton) getActivity().findViewById(R.id.float);
float.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mRecyclerView.smoothScrollToPosition(0);
android.support.design.widget.Snackbar.make(view, "Scrolled to Top", android.support.design.widget.Snackbar.LENGTH_SHORT)
.setAction("Ok", new View.OnClickListener() {
@Override
public void onClick(View v) {
LinearLayoutManager llm = (LinearLayoutManager) mRecyclerView.getLayoutManager();
llm.scrollToPosition(0);
}
})
.setActionTextColor(getActivity().getResources().getColor(R.color.coloLink))
.show();
}
});
}
Run Code Online (Sandbox Code Playgroud) 我有一个Activity它有一个ActionBar,但我需要改变的图标ActionBar动态,我有一个暂停和播放按钮,我需要更换播放与按钮暂停按钮就可以了用户点击.我搜索过,发现它:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if(DEBUG) Log.i("onCreateOptionsMenu()", "onCreateOptionsMenu() -> LogicAnalizerView");
//menu.add("").setIcon(R.drawable.pause).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.actionbarlogic, menu);
menu.removeItem(R.id.pauseLogic);
return true;
}
Run Code Online (Sandbox Code Playgroud)
因此,通过这种方式,我删除了暂停按钮,我也可以添加它,但它只会在我启动Activity并且ActionBar绘制时发生.我怎么强迫重绘ActionBar?此外,通过这种方式,整个ActionBar重绘.是对的吗?有没有办法只重绘我想要的按钮/图标?
谢谢 :)
我正在尝试使用一个ViewPager内部ScrollView,但ViewPager不会出现.如果我删除ScrollView了ViewPager显示正常.
我用以下方法创建了一个简单的测试项目:
main.xml布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v4.view.ViewPager
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/viewpager" />
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
活动类:
public class ScrollViewWithViewPagerActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ViewPager vp = (ViewPager) findViewById(R.id.viewpager);
vp.setAdapter(new MyPagerAdapter(this));
}
}
class MyPagerAdapter extends PagerAdapter {
private Context ctx;
public MyPagerAdapter(Context context) {
ctx = context;
}
@Override
public int getCount() {
return 2;
}
@Override …Run Code Online (Sandbox Code Playgroud) 我有一个ArrayList自定义对象,我希望能够在屏幕上保存和恢复旋转.
我知道,这是可以做到的onSaveInstanceState和onRestoreInstanceState如果我让ArrayList自己的类,它实现了无论是Parcelable还是Serializable......但是,有没有办法做到这一点,而无需创建另一个类?
android ×10
parcelable ×2
arraylist ×1
cursor ×1
debugging ×1
geolocation ×1
java ×1
layout ×1
object ×1
scroll ×1
scrollview ×1