有谁知道谁在firefox的工具栏上找到事件发生.我想在firefox中的工具栏上进行事件记录.
谢谢
我使用资源编辑器创建了一个工具栏资源(IDR_TOOLBAR),如何使用基本的Win32 API将其添加到窗口?
在我的appDelegate中,在applicationDidFinishLaunching下,我有:
[self.navigationController setToolbarHidden:NO];
Run Code Online (Sandbox Code Playgroud)
在子视图中,在viewDidLoad下我有:
[self.navigationController setToolbarHidden:YES animated:YES];
Run Code Online (Sandbox Code Playgroud)
但是,在返回导航控制器时,工具栏仍保持隐藏状态.我已经尝试将它添加到RootViewController但没有成功.我无法弄清楚出了什么问题.
[self.navigationController setToolbarHidden:NO animated:YES];
Run Code Online (Sandbox Code Playgroud) 当我从ActionBar更改为Toolbar时遇到了很多问题.我在这里列出了它们
1)我有许多使用backstack添加/替换的片段.按下后退按钮时一切正常,但当我更改为工具栏时,按下后退按钮时应用程序关闭.
2)弹出菜单的背景是黑色的.
<item name="android:popupMenuStyle">@style/PopupMenu</item>
<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
即便这样也没有用.
如果我使用AppCompat.Light主题,popupmenu的背景颜色是白色,但随后NavigationIndicator图标和所有变黑
3)这是我的菜单风格.这里没有显示id为"add"的项目,而是像往常一样使用了showAsAction.它在菜单中(菜单在按下3个垂直点按钮时膨胀),但图标不可见.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".com.hirak.assistere_doit.do_it_main_screen">
<item android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="Settings" />
<item android:id="@+id/add"
android:icon="@drawable/add"
android:showAsAction="always"/>
</menu>
Run Code Online (Sandbox Code Playgroud) 我想用Twitter App等徽标替换工具栏中的标题.
我想我们可以像这样以编程方式替换它:
mToolbar = (Toolbar) findViewById(R.id.app_toolbar);
mToolbar.setLogo(R.drawable.ic_logo);
Run Code Online (Sandbox Code Playgroud)
但我想直接在我的XML工具栏声明中替换它,但我看不到属性app:logo
或android:logo
.
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/app_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/MyCustomToolBarTheme" />
Run Code Online (Sandbox Code Playgroud)
请帮帮我,谢谢.
这是我的布局 xml 代码
我已经有了 listview 滚动侦听器的回调,但如果我这样做
collapsingToolbarLayout.setVisibility(View.GONE);
Run Code Online (Sandbox Code Playgroud)
它的简单隐藏工具栏代替滚动效果,但我想要滚动效果请帮助。
<android.support.design.widget.AppBarLayout
android:id="@+id/id_toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:visibility="gone"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|exitUntilCollapsed" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/id_toolbar_container">
<android.support.design.widget.AppBarLayout
android:id="@+id/id_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
//This is the toolbar which i want to hide on scroll of listview
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="enterAlwaysCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="5dp"
app:tabMinWidth="75dp"
app:tabIndicatorColor="@color/deep_blue"
app:tabSelectedTextColor="@color/background"
app:tabTextAppearance="@style/MyTabLayoutTextAppearance"
app:tabTextColor="@color/myGrey" />
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
我的应用程序中有一个工具栏,我想在应用程序执行期间(换句话说,在运行时)动态修改其内容。
例如,该应用程序可以拍摄和预览照片;一旦预览了这些照片,用户便可以选择一些照片并向服务器执行发送操作。我还希望使用户能够在选择了其中一些照片后将其删除,并且为此,我希望操作栏上的“删除”项(可通过垃圾桶图标识别)仅在一个或多个以上时可见选择了照片。
这可能吗?如果是,怎么办?
换句话说,更笼统地说,我想控制工具栏中的项目(可见性),将代码设置为仅当某些条件为“真”时(在上述示例中,当选择照片时,在另一个示例中,当用户登录时)和“ false”(用户未登录时)不可见。
现在,我只需要在工具栏中“删除”(或使它们不可见),但是知道是否可以在运行时在工具栏中添加项目也很有用。
我添加了一些有助于理解问题的代码。
“ / res / layout”中的app_bar.xml文件,以图形方式定义工具栏
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:theme="@style/ToolbarTheme" />
Run Code Online (Sandbox Code Playgroud)
menu_resources.xml文件,用于定义工具栏项
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- "User favourite function", should appear as action button if possible -->
<item
android:id="@+id/action_app_icon"
android:icon="@mipmap/ic_launcher"
android:title="@string/action_bar_app_icon"
app:showAsAction="always" />
<!-- Settings, should always be in the overflow -->
<item
android:id="@+id/action_delete"
android:icon="@drawable/trash"
android:title="@string/action_bar_delete"
app:showAsAction="always"/>
<!-- Settings, should always be in the overflow -->
<item
android:id="@+id/action_settings"
android:icon="@drawable/settings" …
Run Code Online (Sandbox Code Playgroud) 我想在某些情况下在工具栏中显示后退按钮,并将其隐藏在另一种情况下。我写了下面的代码:
public void setupToolbar() {
if (mStacks.get(mCurrentTab).size() > 1) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
toolbar.setNavigationOnClickListener(v -> onBackPressed());
} else {
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false);
}
}
Run Code Online (Sandbox Code Playgroud)
但是我的问题是当我将主页按钮设置为 false 时,即使第一个条件变为真,它也不再可见。有谁能够帮助我?
各位开发者大家好,
我有一个包含多个片段的活动。我希望当片段更改时,工具栏的标题也会更改。你们中大概有多少人知道
toolbar.setTitle("title")
Run Code Online (Sandbox Code Playgroud)
当
getSupportActionBar().setTitle("title")
Run Code Online (Sandbox Code Playgroud)
工作正常。
但我无法getSupportActionBar()
从我的片段中调用,因为它不是静态方法。有人知道如何解决这个问题吗?
也谢谢你问候南瓜
我很难将自定义NSToolbarItem添加到现有工具栏。
NSToolbar是在NSWindowController中创建的,然后我有一个函数以编程方式填充工具栏项,代码为:
public func populateFileToolbarItem(_ toolbar: NSToolbar) -> Void{
let itemId = NSToolbarItem.Identifier("FILE_OPEN")
let index = toolbar.items.count
var toolbarItem: NSToolbarItem
toolbarItem = NSToolbarItem(itemIdentifier: itemId)
toolbarItem.label = String("File")
toolbarItem.paletteLabel = String("Open File")
toolbarItem.toolTip = String("Open file to be handled")
toolbarItem.tag = index
toolbarItem.target = self
toolbarItem.isEnabled = true
toolbarItem.action = #selector(browseFile)
toolbarItem.image = NSImage.init(named:NSImage.folderName)
toolbar.insertItem(withItemIdentifier: itemId, at: index)
}
Run Code Online (Sandbox Code Playgroud)
然后我调用了此函数,将工具栏项添加到windowController中的现有工具栏
.......
populateFileToolbarItem((self.window?.toolbar)!)
self.window?.toolbar?.insertItem(withItemIdentifier: NSToolbarItem.Identifier.flexibleSpace, at: (self.window?.toolbar?.items.count)!)
self.window?.toolbar?.insertItem(withItemIdentifier: NSToolbarItem.Identifier.print, at: (self.window?.toolbar?.items.count)!)
print("after toolbaritems were inserted into toolbar. \(String(describing: self.window?.toolbar?.items.count))")
......
Run Code Online (Sandbox Code Playgroud)
控制台打印输出显示,工具栏仅添加了两个工具栏项。
....... …
Run Code Online (Sandbox Code Playgroud) 我现在在android上,我试图使用kotlin在工具栏上添加后退按钮,几乎尝试了网上发布的所有方法,它根本不起作用,总是因未知原因崩溃。有人可以帮忙吗?
class MainActivity : BaseActivity() {
override fun getLayoutId(): Int {
return R.layout.activity_main
}
override fun initData() {
super.initData()
val testButton = findViewById<Button>(R.id.testButton)
testButton.setOnClickListener{
startActivity<RegistrationActivity>()
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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=".MainActivity">
<include android:id="@+id/navBarView" layout="@layout/toolbar"/>
<Button
android:id="@+id/testButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="92dp"
android:layout_marginBottom="533dp"
android:height="50dp"
android:text="click me"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/navBarView" />
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
// 下面是工具栏 xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/white"
app:titleTextColor="@color/white"
app:popupTheme="@style/ThemeOverlay.AppCompat.ActionBar" >
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:src="@mipmap/title_view_image"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:gravity="center"
android:text="Toolbar" …
Run Code Online (Sandbox Code Playgroud)