在我的应用中,我添加了Google地图,它们运行正常.我想添加一个PlaceAutocompleteFragment.我正在使用我已经为地图生成的密钥,我已经启用了google.console中的Places Api选项.我已将这些添加到我的build.gradle中:
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用PlacesAutoCompleteFragment时,Android Studio无法解决此问题.
我正在使用viewPager和android.support.design.widget.TabLayout.我的xml是
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/home_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/custom_tab_layout_height"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<!-- tabs -->
<android.support.design.widget.TabLayout
android:id="@+id/home_tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_tab_layout_height"
android:layout_alignParentBottom="true"
app:tabGravity="fill"
android:background="@color/light_blue_low_opacity"
app:tabIndicatorHeight="0dp"
app:tabMode="fixed"
app:tabPaddingEnd="0dp"
app:tabPaddingStart="0dp"
app:tabSelectedTextColor="@color/light_green"
app:tabTextAppearance="@style/HomeTabsTextAppearance"
app:tabTextColor="@color/white" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我将viewPager设置如下
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.home_container);
mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setPagingEnabled(false);
mViewPager.setOffscreenPageLimit(5);
tabLayout = (TabLayout) findViewById(R.id.home_tabs);
tabLayout.setTabTextColors(ContextCompat.getColorStateList(this, R.color.color_home_tabs));
tabLayout.setupWithViewPager(mViewPager);
Run Code Online (Sandbox Code Playgroud)
我的tabListener是
tabLayout.setOnTabSelectedListener(
new TabLayout.ViewPagerOnTabSelectedListener(mViewPager) {
@Override
public void onTabSelected(TabLayout.Tab tab) {
super.onTabSelected(tab);
int position = tab.getPosition();
mViewPager.setCurrentItem(position);
String tab0TextUnSelected = "<font color='" + ContextCompat.getColor(getApplicationContext(), R.color.white) + "'> " + getResources().getString(R.string.home_tab1) + …Run Code Online (Sandbox Code Playgroud) 我已经实现了RecyclerView它,它工作正常.我有一个ArrayList包含Recycler视图的数据.每个项目的布局都很复杂.它包含两个frameLayout.framelayout1包含图像和文本,framelayout2包含图像和四个文本.当用户点击framelayout1时,我想打开Activity1,当用户点击framelayout2时,我想打开Activity2.我已经搜索的onClick在回收站查看,我发现非常有用此.但是如何获取arrayList的位置以便通过activity1或activity2中的Intent传递它?
我正在使用autoComplete Places API和google maps我的活动.我想删除Powered by google自动完成Places API下拉列表中出现的徽标,但我发现只有javascript的解决方案不适用于android.