- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的代码显示以下错误:
setSupportActionBar(toolbar);
ERRO: Cannot Resolve method setSupportActionBar(android.support.v7.widget.Toolbar);
getSupportActionBar();
ERROR: Cannot resolve method'getSupportActionBar();
我的代码如下:
MapsActivity.java
package com.thiagosaad.filadeatendimento;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.thiagosaad.filadeatendimento.tab.TabViewPagerAdapter;
import com.thiagosaad.filadeatendimento.tab.fragments.InfoMapFragment;
import com.thiagosaad.filadeatendimento.tab.fragments.UserAccountFragment;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
// GOOGLE MAPS API CONFIG
private GoogleMap mMap;
// TABLAYOUT CONFIG
private Toolbar toolbar;
private TabLayout tabLayout;
private ViewPager viewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
// TAB LAYOUT CONFIG
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
viewPager = findViewById(R.id.tabViewPager);
setupViewPager(viewPager);
tabLayout = findViewById(R.id.tabMenu);
tabLayout.setupWithViewPager(viewPager);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
private void setupViewPager(ViewPager viewPager) {
TabViewPagerAdapter adapter = new TabViewPagerAdapter(getSupportFragmentManager());
adapter.addFrag(new UserAccountFragment(), "ONE");
adapter.addFrag(new InfoMapFragment(), "TWO");
viewPager.setAdapter(adapter);
}
}
activity_maps.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fieldList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="top|left"
android:layout_marginStart="11dp"
android:adjustViewBounds="true"
android:clickable="true"
android:fadeScrollbars="false"
android:src="@android:drawable/ic_menu_sort_by_size"
android:visibility="visible"
app:backgroundTint="@android:color/holo_orange_light"
app:fabSize="normal" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/updateMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/fieldList"
android:layout_gravity="top|left"
android:layout_marginStart="65dp"
android:adjustViewBounds="true"
android:clickable="true"
android:fadeScrollbars="false"
android:src="@android:drawable/ic_popup_sync"
android:visibility="visible"
app:backgroundTint="@android:color/holo_orange_light"
app:fabSize="normal" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/myLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_gravity="top|right"
android:layout_marginEnd="11dp"
android:adjustViewBounds="true"
android:clickable="true"
android:fadeScrollbars="false"
android:foregroundGravity="top|right"
android:src="@android:drawable/ic_menu_mylocation"
android:visibility="visible"
app:backgroundTint="@color/colorPrimaryDark"
app:fabSize="normal" />
<android.support.design.widget.TabLayout
android:id="@+id/tabMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="@android:color/holo_orange_light"
android:foregroundGravity="bottom|center_vertical|center_horizontal|center"
app:tabIndicatorColor="@color/colorPrimary">
<android.support.design.widget.TabItem
android:id="@+id/userAccount"
android:foregroundGravity="bottom|center_vertical|center_horizontal|center"
android:icon="@android:drawable/ic_menu_myplaces"
android:visibility="visible" />
<android.support.design.widget.TabItem
android:id="@+id/infoMap"
android:foregroundGravity="bottom|center_vertical|center_horizontal|center"
android:icon="@android:drawable/ic_dialog_info"
android:visibility="visible" />
<android.support.v4.view.ViewPager
android:id="@+id/tabViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.TabLayout>
</RelativeLayout>
</FrameLayout>
TabViewPagerAdapter.java
package com.thiagosaad.filadeatendimento.tab;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.util.ArrayList;
import java.util.List;
public class TabViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public TabViewPagerAdapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFrag(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}
UserAccountFragment.java
package com.thiagosaad.filadeatendimento.tab.fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.thiagosaad.filadeatendimento.R;
/**
* Created by thiago.saad on 09/03/2018.
*/
public class UserAccountFragment extends Fragment {
public UserAccountFragment(){
// OBRIGATORIO TER O CONSTRUTOR VAZIO
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_user_account, container, false);
}
}
最佳答案
setSupportActionBar()是 AppCompatActivity
上的一个方法。
改变
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
到
public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback
关于android - 如何在MapFragment中创建Tab和PageView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49199849/
我在看 Tabs UI 的选项。默认行为是它们水平堆叠。有没有办法改变它? 我想堆叠Tabs垂直。它将节省大量的 UI“不动产”,尤其是在移动应用程序 UI 中。 最佳答案 尝试这个: Tabs ta
问题:在 Zsh 中使用 TAB 向后导航,类似于在 Firefox 中 Shift-TAB Shift-TAB 应该执行的操作示例 我在终端中运行以下代码 ls 我明白了 A B C D E F
有很多人想知道如何完成制表符。这不是这些问题之一。问题是如何将 tab 键分配给 tab 补全? alt-tab/esc-tab 很痛苦。在面板禁用模式选项卡完成工作,这让我暂时...但我仍然希望面板
所以我有一个带有 3 个屏幕的 TabNavigator。 import React from 'react'; import {TabNavigator,createBottomTabNavigat
我想触发一个事件,例如当我在文本框中按 Tab 键时显示警报消息。 $("input").blur(function (e) { if (e.which == 9) alert(
我将这段代码设置为创建一个选项卡式菜单,它显示为一个选项卡式菜单,但当我加载网站时,选项卡在单击时不会改变。在“检查元素”中它说 $( "#tabs").tabs();不是函数。我不知道下一步要解决这
表单中有多个输入字段的示例,因为有一些字段在此之前会自动填充,如果我按 Tab 键,那么它应该跳过该自动填充的输入字段并应转到空白输入字段 我尝试过,但是当我开始在空白输入中写入时会发生什么,它也会自
我想写一个小的 chrome 扩展程序,它应该从网页 A(当前网页)获取信息,将选项卡更新到网页 B,然后将代码注入(inject)网页 B。不幸的是,以下代码正在将网页更新到 B 但注入(injec
如果当前事件选项卡中的表单很脏,我试图阻止 mat-tab 的选项卡更改。 但是我找不到拦截选项卡更改事件的方法。 // Tab 0 Content // Tab
我已从 MacOS Mojave 上的默认终端切换到 iterm2 .我有一个关于从当前选项卡打开新选项卡的问题。 确实,我希望与上一个当前选项卡处于同一路径。 为此,我执行了经典程序,即转到 ite
我在我的网站的两页上有此代码,但在一页上该功能不起作用。 Firebug 向我显示“$(...).tabs 不是函数”。我不明白为什么,谁能告诉我什么是错的? 这是有效的: http://www.in
我需要可靠的方法来为 Windows 和 XP 创建 %tab% (包含一个制表符)。 SET TAB=" " 应该适用于 Windows 7(未测试)但不适用于 Win XP(已测试)。 这个 fo
我正在尝试使用 RMarkdown 制作静态网页。我想定义一个 UI,它有第一层选项卡,然后是第一层下面的选项卡。我已经在 RMarkdown: Tabbed and Untabbed heading
我正在尝试使用 RMarkdown 制作静态网页。我想定义一个 UI,它有第一层选项卡,然后是第一层下面的选项卡。我已经在 RMarkdown: Tabbed and Untabbed heading
我在使用 chrome.tabs.create 方法打开多个选项卡时遇到问题。我正在尝试使用 chrome.tabs.create 循环打开大约 9 个选项卡,但打开的选项卡数量仅限于 4 个。看起来
我正在使用 Material ui 的标签,并且能够对标签的指示器进行更改。但是,我正在尝试使用样式将每个选项卡的指示器宽度减小到某个固定宽度。但似乎指标以一些计算值定位在左侧,并且给它一个宽度不会使
我在 OS X 终端中使用 emacs 24.3,并且遇到了一些奇怪的事情。 在 markdown-mode.el 中,tab 键通过 (define-key map (kbd "") 'markdo
在 Chrome 开发者工具上 Uncaught (in promise) Error: There is no clipping info for given tab at E._handleRes
在vim中,我想将:tabnew缩短为:tn,将:tabp缩短为:th,将:tabn缩短为:tl在我的.vimrc中。知道我将如何重新映射这样的命令吗? 最佳答案 使用cabbrev: ca tn t
我读过几个主题,讨论 IE 中的地址栏在使用 TAB 时基本上是第一个获得焦点的主题(MSDN 自己的文档讨论了这一点)。 然而,我也见过一些情况,但情况并不总是如此...... 我有一个母版页,内容
我是一名优秀的程序员,十分优秀!