我怎样才能PlaceAutocompleteFragment解决?
嗨伙计们,我正在尝试使用新的PlaceAutocompleteFragment.我尝试使用以下代码:
<fragment
android:id="@+id/place_autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
Run Code Online (Sandbox Code Playgroud)
此代码示例只是一个副本.它来自这个网站.但是PlaceAutocompleteFragment在我的案例中没有得到解决.我该如何解决这个问题?我认为解决方案必须非常简单.但是我一直在寻找相当长的一段时间.
我有一个mainactivity,包括一个带有ViewPager的TabLayout
我添加了3个选项卡,每个选项卡都有单独的片段,其中包含recyclerview,这些recyclerviews有一个复选框,每当我滑动viewpager时我都应该同时更新/刷新(我在共享首选项中保存已检查的位置并通过共享首选项进行更新).
我的问题是每当我检查tab1中的复选框时,tab2没有更新/刷新,直到我向下滚动Recyclerview.和tab3工作正常. 而且我在logcat中也得到了一个奇怪的警告.
03-05 09:35:53.345 4317-4327/com.example.rubin W/art: Suspending all threads took: 6.805ms
03-05 09:35:58.310 4317-4317/com.example.rubin W/FragmentManager: moveToState: Fragment state for Tab3{10a5f1f0 #2 id=0x7f0d00b6} not updated inline; expected state 3 found 2
03-05 09:36:01.363 4317-4317/com.example.rubin W/FragmentManager: moveToState: Fragment state for Tab1{2d9aa887 #1 id=0x7f0d00b6} not updated inline; expected state 3 found 2
Run Code Online (Sandbox Code Playgroud)
我的PagerAdapter
public class PagerAdapter1 extends FragmentStatePagerAdapter {
int mNumOfTabs;
public PagerAdapter1(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
@Override
public Fragment getItem(int position) {
switch (position) …Run Code Online (Sandbox Code Playgroud) 我正在使用fragmentActivity for maps.In Java类在setContentView上获取错误.我的Mapscreen.java就像:它在某些设备上工作正常,只显示棉花糖的崩溃.或者还有其他原因吗?
public class MapScreen extends FragmentActivity implements LocationListener,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_screen);
....
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
googleMap = fm.getMap();
}
and my xml has fragment using SupportMapFragment as well. map_screen.xml is like :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<ImageView
android:id="@+id/startActivityButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="44dp"
android:background="@drawable/end_meetup_btn"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我无法找到相同的问题在Marshmallow中遇到崩溃:"二进制XML文件行#7:错误膨胀类片段"请建议! 试图找到"引起:java.lang.NullPointerException:尝试在空对象引用上调用虚方法'boolean …
我通过使用android.permission.GET_ACCOUNTS权限获取电子邮件ID .
try {
Account[] accounts = AccountManager.get(this).getAccountsByType("com.google");
for (Account account : accounts) {
emailid = account.name;
Log.e("account",emailid);
}
} catch (Exception e) {
Log.i("Exception", "Exception:" + e);
}
Run Code Online (Sandbox Code Playgroud)
此代码适用于Lollipop 5.1之前的所有设备.但它不适用于Marshmallow 6.0.
任何人都可以帮我解决这个问题.我甚至没有在logcat中收到任何错误.