我一直在寻找这个问题,但我还是找不到解决方案.对于我的DrawerLayout设计,我不会使用listview而是使用linearlayout作为我的视图的容器.我首先通过在linearlayout中添加一个按钮来测试它,但我无法点击它.继承了XML.
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/left_drawer"
android:background="@color/white"
android:orientation="vertical"
android:layout_gravity="start"
android:layout_width="250dp"
android:layout_height="match_parent">
<Button
android:id="@+id/btn_test"
android:text="TEST"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<FrameLayout
android:id="@+id/container_fragment2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="1dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
在java中,我还尝试在按钮加载和工作后将文本放在按钮中.唯一不起作用的是我点击它.抽屉就会关闭.
/**Init Drawer*/
private void initDrawer(){
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerContainer = (LinearLayout) findViewById(R.id.left_drawer);
//mDrawerContainer.setOnClickListener(new DrawerItemClickListener());
mDrawerContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context,"initDrawer",Toast.LENGTH_SHORT).show();
}
});
btn_test = (Button)mDrawerContainer.findViewById(R.id.btn_test);
btn_test.setOnClickListener(new View.OnClickListener() { //this is not working,i cant click the button
@Override
public void onClick(View v) { …Run Code Online (Sandbox Code Playgroud) 我想在我的主页上插入一个点击呼叫按钮.这是我使用Bootstrap(Bootstrap 3.2.0)构建的第一个站点.
请查看代码并帮我弄清楚我做错了什么.谢谢
您可以在这里访问该网站.
<button type="button" class="btn btn-primary btn-xlg" href="tel:713-992-0916" style="padding:20px;background-color:rgba(0,0,238,.5)">
Click to Call <span class="glyphicon glyphicon-earphone" style="padding-left:10px; padding-right:10px;"></span>713-992-0916
</button>
Run Code Online (Sandbox Code Playgroud) 我有一组按钮,形成一个选择作为我的表单的一部分.
代码如下:
<div class="form-group">
<div>
<h4>Extras</h4>
</div>
<div class="radio-inline">
<input type="button" class="btn btn-default inline" name="extra" value="Garden" >
<input type="button" class="btn btn-default inline" name="extra" value="Balcony">
<input type="button" class="btn btn-default inline" name="extra" value="Parking">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
但是,我想让选项不相互排斥,即你可以选择'花园'和'阳台' - 我想保留按钮样式.
有人能帮忙吗?
编辑:好的 - 现在有一些奇怪的事情 - 得到这个代码.
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type="checkbox" name="garden" checked=""> Garden
</label>
<label class="btn btn-default">
<input type="checkbox"> Balcony
</label>
<label class="btn btn-default">
<input type="checkbox"> Parking
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
当我使用bootply时,多选用户功能很有效 - 当我将它添加到我的页面时 - 它不起作用 - 有没有人知道它为什么会这样?以下是整个页面
<div class="container">
<div class="row"> …Run Code Online (Sandbox Code Playgroud) 我有一个从自定义适配器填充的ListView.每行中都有1个按钮.在xml中,按钮具有传递的onClick属性.我只有xml,而不是任何OnClickListeners集.另请注意,我的CustomActivity中存在public void myMethod(View v).我得到以下异常
10-02 03:01:46.463: E/AndroidRuntime(26857): java.lang.IllegalStateException: Could not find a method myClickHandler(View) in the activity class **android.app.Application** for onClick handler on view class android.widget.Button with id 'myButton'
Run Code Online (Sandbox Code Playgroud)
活动方法:
public void myClickHandler(View v) {
... do stuff here...
}
Run Code Online (Sandbox Code Playgroud)
按钮XML:
<Button
android:id="@+id/myButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:background="@drawable/eye_icon"
android:onClick="myClickHandler"
/>
Run Code Online (Sandbox Code Playgroud)
异常中的一个有趣的注释是该应用程序试图在android.app.Application中找到该方法, 而不是在我的自定义Activity中.
有什么建议?
我使用本指南来自定义我使用bootstrap创建的网页中的按钮:
问题是我无法在悬停中保持相同的字体颜色,我无法解释为什么它总是变为深灰色.这是代码:http://codepen.io/anon/pen/ByKZZK
HTML:
<head>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<button href="mailto:abc@def.ghi" class="btn btn-custom btn-lg btn-block">info@mail.org <span class="glyphicon glyphicon-envelope"></span></button>
Run Code Online (Sandbox Code Playgroud)
CSS:
.btn-custom {
color: #FFD180;;
background-color: #483737;
border-color: #357ebd; /*set the color you want here*/
}
.btn-custom:hover, .btn-custom:focus, .btn-custom:active, .btn-custom.active, .open>.dropdown-toggle.btn-custom {
color: #FFD180;
background-color: #837171;
border-color: #837171; /*set the color you want here*/
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我一直在使用Perl Tkx开发GUI,并发现可以使用两个单独的函数来创建按钮.(button和ttk__button).
到目前为止,我发现的唯一区别是button函数似乎居中对齐文本,而ttk__button函数似乎左对齐文本.
示例使用button:
#!/usr/bin/perl
use strict;
use warnings;
use Tkx;
my $text = "Hello\nworld!\n\nThis is some text...";
my $mw = Tkx::widget->new(".");
my $b = $mw->new_button(
-text => $text,
-command => sub { exit; },
);
$b->g_grid;
Tkx::MainLoop()
Run Code Online (Sandbox Code Playgroud)
此脚本将使文本居中:

示例使用ttk__button:
#!/usr/bin/perl
use strict;
use warnings;
use Tkx;
my $text = "Hello\nworld!\n\nThis is some text...";
my $mw = Tkx::widget->new(".");
my $b = $mw->new_ttk__button(
-text => $text,
-command => sub …Run Code Online (Sandbox Code Playgroud) 我使用XML在android 5.0中成功创建了一个涟漪按钮.我的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<!-- the flat button to be used in app -->
<!-- define the ripple -->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<!-- the ripple object -->
<item android:id="@android:id/mask">
<!-- button shape (w/ radius) -->
<shape android:shape="rectangle">
<!-- radius of vertices -->
<corners
android:topLeftRadius="7dp"
android:topRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp" />
<!-- color accent (not working) -->
<solid android:color="?android:colorAccent" />
</shape>
</item>
</ripple>
Run Code Online (Sandbox Code Playgroud)
我的按钮有问题:按钮的背景颜色不会改变.我也尝试过:
<solid android:color="#0000ff" />
Run Code Online (Sandbox Code Playgroud)
背景仍然保持透明(colorAccent也不起作用).
如果没有通过,我应该如何将矩形(按钮的)背景设置为蓝色
<solid/>
Run Code Online (Sandbox Code Playgroud)
属性?
谢谢
所以这是我的第一个应用程序,我正在尝试编码,需要一些按钮帮助.在寻找答案后,我找不到一个我理解的答案.我希望能够为应用程序创建不同的页面并将imagebuttons链接建立到这些页面.这是我按钮的最基本代码.请尝试解释在哪里放置代码等.提前感谢.
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:background="@drawable/home_button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:nestedScrollingEnabled="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我正在尝试让标准的Android ToggleButton呈现某种自定义样式:在未选中状态下,不显示边框/背景填充,在选中状态下,背景填充显示,当按下(选中或未选中)时会产生波纹效果显示为从一种状态过渡到另一种状态。
我已经做好了一切,大部分情况下都使用它作为ToggleButton的背景:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ripple" android:state_pressed="true"/>
<item android:drawable="@drawable/checked_bg" android:state_checked="true"/>
<item android:drawable="@android:color/transparent"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
波纹:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight" >
<item
android:id="@android:id/mask">
<color
android:color="@android:color/white" />
</item>
</ripple>
Run Code Online (Sandbox Code Playgroud)
checked_bg:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="?android:attr/colorControlHighlight" />
</shape>
Run Code Online (Sandbox Code Playgroud)
但是,当我从选中状态转到未选中状态时,涟漪将实心填充应用于与选中按钮状态填充颜色不匹配的按钮,因此它似乎立即从一种颜色“跳转”到另一种颜色。我相信这是因为我在检查状态背景填充和波纹颜色上都使用了colorControlHighlight,因此波纹最终以该颜色开始,并以另一种稍微浅一点的颜色开始...
但是,我不能简单地将选中状态的背景填充更改为这种较浅的颜色,因为这会使我检查/打开按钮时看起来很奇怪-它会以较浅的颜色开始,与选中的背景填充相匹配,然后变成较深的颜色,然后立即再次跳至较浅的颜色。
有没有一种干净的方法来解决这个问题?还是我一端卡住了颜色变化?
或者,我可以使用两种不同的纹波,一种用于按下= true和checked = false,另一种用于按下= true和checked = true的情况,对吗?
我正在尝试在我通过Sublime Text2编码并通过Apache运行的网站上实施Google+登录/登录按钮.我是非常新的Web开发和使用localhost/http://127.0.0.1.
所以我的问题就出现了,因为当我在"索引"Chrome HTML文档中有按钮时,它运行正常,我可以使用我的Google +帐户登录.
但是,如果我将网页中的按钮链接到该网页(新文档"登录"Chrome HTML文档),则登录不会通过.它会提取我的帐户,但它不会让我完全登录.
错误错误:origin_mismatch
我想我必须在我的API和Auth中使用我的证书中的JavaScript起源中更改一些内容,但它不会让我添加类似http://localhost/signin.html的内容 .
Origins URIs must not contain a path: http://localhost/signin.html
Run Code Online (Sandbox Code Playgroud)
我怎么能让这个网页访问?
谢谢!
button ×10
android ×5
html ×3
click ×1
css ×1
drawerlayout ×1
forms ×1
google-api ×1
google-plus ×1
hover ×1
listview ×1
onclick ×1
perl ×1
tcl ×1
tkx ×1