- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图有一个标题栏,显示各种图标,单击这些图标将引导用户进入适当的 Activity 页面。不幸的是,我遇到了以下问题:-隐藏 Activity 标题-图标不显示在 Activity 栏上,仅显示为下拉列表
下面是我在 android list 中使用的代码
<activity
android:name="com.dooba.beta.MoodActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
下面是菜单 xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/pageExperience"
android:icon="@drawable/fork_spoon3"
android:title="@string/action_experience"/>
<item android:id="@+id/pageMessaging"
android:icon="@drawable/messageicon"
android:title="@string/action_messaging"/>
<item android:id="@+id/pageEventsBooking"
android:icon="@drawable/fork_spoon3"
android:title="@string/action_book"/>
<item android:id="@+id/pageProfile"
android:icon="@drawable/fork_spoon3"
android:title="@string/action_profile" />
<item android:id="@+id/pageReport"
android:icon="@drawable/fork_spoon3"
android:title="@string/action_report" />
<item android:id="@+id/pageAbout"
android:icon="@drawable/fork_spoon3"
android:title="@string/action_about" />
</menu>
下面是调用菜单的 Activity 代码
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_activity_actions, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.pageExperience:
openPageExperience();
return true;
case R.id.pageMessaging:
openPageMessage();
return true;
case R.id.pageEventsBooking:
openPageBook();
return true;
case R.id.pageProfile:
openPageProfile();
return true;
case R.id.pageReport:
openPageReport();
return true;
case R.id.pageAbout:
openPageAbout();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void openPageAbout() {
// TODO Auto-generated method stub
}
private void openPageReport() {
// TODO Auto-generated method stub
}
private void openPageProfile() {
// TODO Auto-generated method stub
}
private void openPageBook() {
// TODO Auto-generated method stub
}
private void openPageMessage() {
// TODO Auto-generated method stub
}
private void openPageExperience() {
// TODO Auto-generated method stub
}
}
下面是引用标题图标字符串名称的字符串 xml 文件
<string name="action_experience">Experience</string>
<string name="action_messaging">Messaging</string>
<string name="action_book">Book</string>
<string name="action_profile">Profile</string>
<string name="action_report">"Report</string>
<string name="short_name"></string>
<string name="action_about">About</string>
更新:我在尝试实现代码时收到以下问题ActionBar ab = getActionBar();获取操作栏类型不匹配:无法从 android.app.ActionBar 转换为 android.support.v7.app.ActionBar
customActionBarView 无法解析为变量main_activity_actions 无法解析或不是字段
Activity 代码
public class MoodActivity extends Activity {
@Override
public void onResume() {
super.onResume(); // Always call the superclass method first
setCustomActionBarView();
}
private void setCustomActionBarView() {
// TODO Auto-generated method stub
ActionBar ab = getActionBar();
ab.setDisplayHomeAsUpEnabled(false);
ab.setDisplayShowTitleEnabled(false);
ab.setDisplayShowCustomEnabled(true);
if(customActionBarView == null){
LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
customActionBarView = inflator.inflate(R.layout.main_activity_actions,null);
}
ab.setCustomView(customActionBarView);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mood);
final TextView teating = (TextView) this.findViewById(R.id.tdinning);
teating.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MoodActivity.this.startActivity(new Intent(MoodActivity.this, CasualEventsActivity.class));
}
});
final ImageView ieating = (ImageView) this.findViewById(R.id.idinning);
ieating.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MoodActivity.this.startActivity(new Intent(MoodActivity.this, CasualEventsActivity.class));
}
});
final TextView tdrinks = (TextView) this.findViewById(R.id.tcasual);
tdrinks.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MoodActivity.this.startActivity(new Intent(MoodActivity.this, CasualEventsActivity.class));
}
});
final ImageView idrinks = (ImageView) this.findViewById(R.id.icasual);
idrinks.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MoodActivity.this.startActivity(new Intent(MoodActivity.this, CasualEventsActivity.class));
}
});
final TextView tshows = (TextView) this.findViewById(R.id.tshows);
tshows.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MoodActivity.this.startActivity(new Intent(MoodActivity.this, CultureEventsActivity.class));
}
});
final ImageView ishows = (ImageView) this.findViewById(R.id.ishows);
ishows.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MoodActivity.this.startActivity(new Intent(MoodActivity.this, CultureEventsActivity.class));
}
});
final TextView tarts = (TextView) this.findViewById(R.id.tculture);
tarts.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MoodActivity.this.startActivity(new Intent(MoodActivity.this, CultureEventsActivity.class));
}
});
final ImageView iarts = (ImageView) this.findViewById(R.id.iculture);
iarts.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MoodActivity.this.startActivity(new Intent(MoodActivity.this, CultureEventsActivity.class));
}
});
final Button viewall = (Button) this.findViewById(R.id.brandom);
viewall.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MoodActivity.this.startActivity(new Intent(MoodActivity.this, CasualEventsActivity.class));
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_activity_actions, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.pageExperience:
openPageExperience();
return true;
case R.id.pageMessaging:
openPageMessage();
return true;
case R.id.pageEventsBooking:
openPageBook();
return true;
case R.id.pageProfile:
openPageProfile();
return true;
case R.id.pageReport:
openPageReport();
return true;
case R.id.pageAbout:
openPageAbout();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void openPageAbout() {
// TODO Auto-generated method stub
}
private void openPageReport() {
// TODO Auto-generated method stub
}
private void openPageProfile() {
// TODO Auto-generated method stub
}
private void openPageBook() {
// TODO Auto-generated method stub
}
private void openPageMessage() {
// TODO Auto-generated method stub
}
private void openPageExperience() {
// TODO Auto-generated method stub
}
}
更新我现在遇到以下问题:getSupportActionBar();它给了我以下问题:MoodActivity 类型的 getSupportActionBar() 方法未定义
@Override
public void onResume() {
super.onResume(); // Always call the superclass method first
setCustomActionBarView();
}
private void setCustomActionBarView() {
// TODO Auto-generated method stub
ActionBar ab = getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(false);
ab.setDisplayShowTitleEnabled(false);
ab.setDisplayShowCustomEnabled(true);
View customActionBarView;
if(customActionBarView == null){
LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
customActionBarView = inflator.inflate(R.layout.main_activity_actions,null);
}
ab.setCustomView(customActionBarView);
}
最佳答案
ActionBar ab = getActionBar();
ab.setDisplayHomeAsUpEnabled(false);
ab.setDisplayShowTitleEnabled(false);
ab.setDisplayShowCustomEnabled(true);
if(customActionBarView == null){
LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
customActionBarView = inflator.inflate(R.layout.my_custom_view,null);
}
ab.setCustomView(customActionBarView);
它的作用如下:
setDisplayHomeAsUpEnabled(boolean showHomeAsUp)
当您使用抽屉式导航栏并且希望用户在 View 层次结构中向上移动时使用。
setDisplayShowTitleEnabled(boolean showTitle);
用于决定是否显示 Activity 的标题
setDisplayShowCustomEnabled(boolean showCustom);
用于决定是否要为ActionBar
显示自定义 View
然后,您可以使用 customActionBarView.findViewById()
检索图标并向其添加监听器。
关于java - 隐藏操作栏中的标题并显示图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25343243/
我从来没有遇到过这种问题 - 我也不知道为什么.. 有些图标丢失并以“?/!”闪烁显示 发生了什么事? 它是一个提交按钮。我在另一个按钮中有相同的图标 - 那里没问题。 SIGN! 有什
我只需要在单击按钮时显示 ionic 图标。 我试着在那个图标上放一个类并做到了: .icn { visibility: visible; } 但是没有用,有没有人知道另一种方法? 最佳答案 Sho
我用qt在托盘里做了一个应用。在我的电脑上,这是一个很好的项目,我在托盘栏中看到了图标,但是当我将其发布给其他人时,他们看不到该图标,它只是一个可以使用但不显示图标的隐形方 block 。但在我的电脑
我想使用delphi将图标/ bmp绘制到TListView的子项中。但是我不知道该怎么做到。它适用于列表中的第一项,但子项存在问题。 最佳答案 您可以使用CustomDrawSubItem事件。 下
我想将标题栏中的图标设置为应用程序的图标 [[myWindow standardWindowButton:NSWindowDocumentIconButton] setImage:[NSApp app
可以设置一个图标,以便在当前应用程序的每个窗口上使用它。这样我就设置了一次(不是手动在每个窗口上设置)..? 最佳答案 关于这个主题的一个很好的引用在这里 MSDN 。表明您有一个应用程序图标(桌面图
我为自己制作了一个小书签,它的功能很好,但当添加到 Opera 或 Firefox 的工具栏时,它只是呈现浏览器的默认书签图标(分别是地球仪和星星)。我的网站有一个网站图标,窗口、选项卡甚至 [网站]
制表符中的responsiveCollapse 折叠展开功能的默认图标似乎未居中。是否有更改此图标的选项。也许是右下胡萝卜? 最佳答案 responsiveCollapse 格式化程序只是一个像所有其
上面是下拉列表,当单击列表时,其值将与图像一起显示在上面的字段(顺便说一句,这是一个按钮)中。我已经实现了显示文本,但似乎无法显示图像。这是我的标记如下... 广东 @foreach
我想将我们数据库中的电线杆和电缆导出到 Google 地球的 KML 文件中。 对于每个节点,我们都有一个极阵列,电缆始终连接到阵列中的下一个极。 制作简单路径的导出似乎很容易。但是这些路径只是显示一
我想将我们数据库中的电线杆和电缆导出到 Google 地球的 KML 文件中。 对于每个节点,我们都有一个极阵列,电缆始终连接到阵列中的下一个极。 制作简单路径的导出似乎很容易。但是这些路径只是显示一
在 JTable 中显示数据。一列用作字段复选框。问题是在显示ChceckBox 中而不是出现图标true/false。我该如何解决这个问题? 添加数据: private DefaultTableMo
[编辑] 我想使用 DataTable 在 Datagridview 中使用图像。 RadioButton 只是这篇文章的一种简单问题格式。 让我为此澄清一下。 如何使用绑定(bind)样式在 dat
我正在使用 C# 开发 win 表单应用程序。我遇到了一个需要向用户提供 ComboBox 的场景。现在,为了使外观更具吸引力,我想在该组合框的每个项目之前显示一个小图像或图标。 我查看了一些提供此功
我正在 CrossRider 中构建一个扩展。我需要在数据库中保存我有它们的 url 的图像/图标。它们是微小的图像,不会成为数据库中的问题。我可能有类似的东西可以访问 background.js:
我需要使用我的 JavaFX 应用程序中的一些元素,这些元素使用 带有自定义符号/图标的按钮 横幅或背景图像。 此应用程序应该在具有不同屏幕分辨率的多个设备上运行,并且我还(最终)需要缩放图像/图标(
我怎样才能在 android studio 中做这样的事情: 我想要一个导航栏,您可以在其中看到名称、图标以及打开抽屉导航的机会 :D (图片是用Figma制作的) 最佳答案 将重力设置为在 Draw
当我在 ViewPager 中滑动 fragment 时,如何动态更改 Action Bar 的操作按钮图标。取决于 fragment 按钮必须改变状态(图标)。 最佳答案 您可以在 onPrepar
我有两个 while 循环,一个是循环遍历聊天日志以检索日期、用户名、消息,另一个 while 循环 是从单独的表中检索图标这有两列 chars 和 image (image-name.*) 我可以显
我正在尝试重新启动 mysql(一个完全不同的问题),MySql 肯定已安装(版本 14.14),并且根据我收集的信息,我应该在系统偏好设置面板的底部看到它的图标,但它是不在那里。安装过程中是否出现了
我是一名优秀的程序员,十分优秀!