我有一个主要的活动,当我按下一个按钮时,我导航到一个滑动选项卡视图.现在我希望在这些选项卡中有一个可点击按钮,并在按下按钮时显示一个Toast.这是我使用的代码:
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
public class laundry extends Fragment {
Button btn_service;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
return inflater.inflate(R.layout.activity_laundry, container,false);
btn_service = (Button) findViewById(R.id.btn_service);
btn_service.setOnClickListener(this);
}
Run Code Online (Sandbox Code Playgroud)
但findViewById不是此活动的已知符号.是否有另一种方法可以在上面的片段活动中加入可点击按钮?
跑了项目,我得到了这个错误.(我不知道建议的更改是否有效,我的应用程序崩溃了以下错误)这是一个片段活动,我试图在单击按钮时生成一个Toast.
public class in_room_dining extends Fragment
{
Button btn_order;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
// TODO Auto-generated method stub
btn_order.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
Toast.makeText(getActivity(), "text", …Run Code Online (Sandbox Code Playgroud) 我为我的Delphi 6应用程序创建了清单文件,因此它可以根据Windows定义的主题(控件6.0)显示控件.一切看起来很好,除了TBitBtn组件,使用遗留主题显示:

无论当前主题如何,即使没有为TBitBtn组件分配图像,Windows XP和Windows 7上的行为也是相同的.
现在,当我TButton在表单上放置常规组件时,它会显示OK.如果我在运行时(使用SendMessage(Handle, BM_SETIMAGE, IMAGE_ICON, LPARAM(Icon)))以编程方式将图像设置为此按钮,它会立即将其样式恢复为旧样式.
有没有办法要么TBitBtn使用正确的样式,要么在常规上显示字形TButton而不恢复到Delphi 6中的遗留字体?
我正在尝试在图标和按钮上的某些文本之间添加垂直分隔符,但它只是将所有内容都推下来.这是为什么?
.btn {
height: 22px;
border: 1px solid #B9B9B9;
font-weight: normal;
font-size: 11px;
color: #003E7E;
text-align: left;
line-height: 12px;
width: 200px;
}
.separator {
content: '';
display: inline-block;
background: #888;
margin: 0px 4px;
height: 18px;
width: 1px;
}Run Code Online (Sandbox Code Playgroud)
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet"/>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet"/>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" class="btn">
<span class="icon-plus"></span>
<span class="separator"></span>
ABC0102165
</button>Run Code Online (Sandbox Code Playgroud)
我已经阅读了几篇PyQt教程,他们在Strings中使用了一个&符号(&)来标记按钮.例如:
self.submitButton = QPushButton("&Submit")
Run Code Online (Sandbox Code Playgroud)
我搜索了一些解释,但有一个问题是,常见的搜索引擎认为它们非常聪明并且忽略了&字符,这很烦人.当我在它周围添加引号时,它只会让我找到更少的结果而没有,这解释了有关奇怪的'&'字符的任何内容.
我也试过在python控制台:
a = "&abc"
b = "abc"
a == b
Run Code Online (Sandbox Code Playgroud)
返回false.然后我尝试将它作为print函数的参数:
print(a)
print(b)
Run Code Online (Sandbox Code Playgroud)
哪个简单的打印:
&abc
abc
Run Code Online (Sandbox Code Playgroud)
所以我仍然不知道该怎么做.
我有一个循环,我想停止使用按钮.编辑以便更好地理解:
我确实意识到在循环运行时你无法停止按钮,因为只要当前的UI正在运行它就无法工作.我真正要求的是创建线程或使用BGWorker来阻止它的最有效方法.我见过一些方法,但大部分方法都是针对Java而不是C#.
我想做的是:
private void start_Click(object sender, EventArgs e)
{
for(int i = 0; i < nums; i++)
{
doSomething();
}
}
private void stop_Click(object sender, EventArgs e)
{
stops start_Click()
}
Run Code Online (Sandbox Code Playgroud) 我试图在按钮点击时添加一个面板.我的代码在下面,我做到了.但现在我正试图在我的面板上放置其他按钮等,当你点击第一个按钮和面板幻灯片时,我没有任何新按钮.
//Constants
const int AW_SLIDE = 0X40000;
const int AW_HOR_POSITIVE = 0X1;
const int AW_HOR_NEGATIVE = 0X2;
const int AW_BLEND = 0X80000;
[DllImport("user32")]
static extern bool AnimateWindow(IntPtr hwnd, int time, int flags);
photosflag=0;
private void photosbutton_Click(object sender, EventArgs e)
{
if (photosflag == 0)
{
object O = Controller.Properties.Resources.ResourceManager.GetObject("photospressed");
photosbutton.Image = (System.Drawing.Image)O;
photosflag = 1;
int ylocation = photosbutton.Location.Y;
//Set the Location
photospanel.Location = new Point(101, ylocation);
//Animate form
AnimateWindow(photospanel.Handle, 500, AW_SLIDE | AW_HOR_POSITIVE);
}
else
{
object O = …Run Code Online (Sandbox Code Playgroud) 我有一个带有两个按钮的NSAlert:
var al = NSAlert()
al.informativeText = "You earned \(finalScore) points"
al.messageText = "Game over"
al.showsHelp = false
al.addButtonWithTitle("New Game")
al.runModal()
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但我不知道如何识别,用户按下了哪个按钮.
我在linearlayout horizontalscrollview中动态创建按钮,然后单击我获得选定的按钮位置.
我想知道如何更改所选按钮的文字颜色?
这是我的代码.
String[] categories = {"SUN","MON", "TUS", "WED", "THU", "FRI", "SAT", "SUN","MON", "TUS", "WED", "THU", "FRI", "SAT"};
private LinearLayout ll;
Button btn;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ll = (LinearLayout) findViewById(R.id.hsvLinearLayout);
for(int i = 0; i < categories.length; i++) {
btn = new Button(this);
btn.setText(categories[i]);
btn.setBackgroundColor(Color.parseColor("#ffffff"));
btn.setOnClickListener(buttonClick);
ll.addView(btn);
int idx = ll.indexOfChild(btn);
btn.setTag(Integer.toString(idx));
// btn.setId(idx);
}
}
OnClickListener buttonClick = new OnClickListener() {
public void onClick(View v) {
String idxStr = Integer.toString(ll.indexOfChild(v));
//(String)v.getTag();
Toast.makeText(MainActivity.this, idxStr, 6000).show(); …Run Code Online (Sandbox Code Playgroud) I am trying create one app and in my app I am trying to create border at bottom in button,but when I run application it shows border at top only,can anybody tell how to achieve this..following is my xml of UI?.........
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:context="com.example.button_pressed_effect_example.MainActivity" >
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="One"
android:id="@+id/button1"
android:background="@drawable/custom_btn_black_orange"
android:drawableBottom="@drawable/liti"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Two"
android:id="@+id/button2"
android:background="@drawable/custom_btn_black_orange"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
liti.xml
<layer-list /android">
<item android:left="10dp" android:bottom="10dp">
<shape android:shape="line">
<stroke android:width="10dp" android:color="#ffffff" />
</shape>
</item>
</layer-list> …Run Code Online (Sandbox Code Playgroud) Html按钮是
<button class="btn" type="submit"><i class="icon-search"></i> Go</button>
我把它变成了Yii
<?php
echo CHtml::submitButton('Go', array('id' => 'btSubmit',
'class' => 'btn',
'name' => 'files'
));
?>
Run Code Online (Sandbox Code Playgroud)
我该如何添加按钮