标签: button

WPF如何让UserControl继承Button?

我创建了一个UserControl,它由一对椭圆和标签组成.我把它添加到另一种形式就好了,看起来很漂亮.

然后我开始添加一些事件处理程序,发现我所做的控件没有公开Click事件.哎呀.容易修复,对吧?回到我制作的UserControl上的代码隐藏,让它继承Button.

不幸的是,这样做会导致"MyControl的部分声明不能指定不同的基类"消息.这是一个惊喜,因为我没有声明任何其他基类.搜索有问题的部分也没有返回任何结果.

有没有办法打败这个问题?如果没有,这里最简单的解决方法是什么?我的目标只是在UserControl上获取Click事件.

wpf user-controls button

12
推荐指数
1
解决办法
9565
查看次数

如何将字符串形式的文本数据传递给下一个活动?

我正在开发一个Android应用程序,其中我已经采取了两个按钮和一个编辑文本框.我想通过点击其中一个按钮将编辑文本框的数据从字符串传递到下一个活动,如何将文本传递给下一个活动并在新启动的活动中接收该文本,以便使用文本在那里面.

我的第一个活动的代码是

EditText Urlis=(EditText)findViewById(R.id.entry);
final Button button = (Button) findViewById(R.id.ok);
final Intent i=new Intent(this , RSSReder.class);
final String choice=Urlis.getText().toString();

i.putExtra("key", choice);
button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        startActivity(i);
    }    
});  
Run Code Online (Sandbox Code Playgroud)

对于被叫活动是

public class RSSReder extends Activity implements OnItemClickListener {

    public String RSSFEEDOFCHOICE;
    public final String tag = "RSSReader";
    private RSSFed feed = null;

    /** Called when the activity is first created. */

    public void onCreate(Bundle abc) {
        super.onCreate(abc);
        setContentView(R.layout.next1);

        Intent i = getIntent();
        RSSFEEDOFCHOICE =i.getStringExtra("key");

        // go get …
Run Code Online (Sandbox Code Playgroud)

string android button android-activity

12
推荐指数
1
解决办法
3万
查看次数

如何通过代码设置drawableRight资源?

单击按钮后,我试图在按钮的右侧设置图像.我想通过代码来做到这一点.

我已经看到如何通过代码更改后台资源,但我无法找到任何显示如何通过代码更改侧面的示例.可能吗?

android button drawable

12
推荐指数
2
解决办法
1万
查看次数

Android以编程方式设置按钮文本

有谁知道如何以编程方式设置按钮的文本?

事情是我不是从主布局(setContentView)调用它我在一个视图中调用它在asynctask heres之后膨胀我试过但这是在第二行给出一个空指针异常

Button mButton=(Button)findViewById(R.id.contact);
        mButton.setText("number");
Run Code Online (Sandbox Code Playgroud)

继承我的布局,我在呼叫按钮

   <Button
       android:id="@+id/contact"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/address"
       android:layout_toLeftOf="@+id/badge"
       android:background="@drawable/ic_btn_call"
       android:textSize="10dp"
       android:textStyle="bold"
       android:textColor="@color/white"/>
Run Code Online (Sandbox Code Playgroud)

在这里我的观点我正在膨胀

ClubInfo = LayoutInflater.from(getBaseContext()).inflate(R.layout.clubinfocell,
                null);

        TextView TeamNameText = (TextView) ClubInfo.findViewById(R.id.TeamName);
        TeamNameText.setText(teamName);

        TextView AddressText = (TextView) ClubInfo.findViewById(R.id.address);
        AddressText.setText(address1);



        Button mButton=(Button)ClubInfo.findViewById(R.id.contact);
        mButton.setText(telephone);
Run Code Online (Sandbox Code Playgroud)

android button

12
推荐指数
1
解决办法
6万
查看次数

如何在XML文件中设置所选/未选定Button的背景

我有自定义按钮应该具有不同的背景,具体取决于它们是否被选中.我想知道是否有办法在XML文件中说明这一点.我有一个Celsius按钮和一个华氏按钮.我希望它能够工作,如果选择了一个,它会保持"按下"而无法点击,而另一个按钮可以被按下.

        <Button
            android:id="@+id/celsiusButton"
            android:text="C"
            android:background="@drawable/button_unpressed_shape"
            android:layout_weight="3"
            android:layout_height="match_parent"
            android:layout_width="0dip"
            android:gravity="center" />

        <Button
            android:id="@+id/fahrenheitButton"
            android:text="F"
            android:background="@drawable/button_unpressed_shape"
            android:layout_weight="3"
            android:layout_height="match_parent"
            android:layout_width="0dip"
            android:gravity="center" />
Run Code Online (Sandbox Code Playgroud)

摄氏度按钮默认为选中状态.我在我的代码中尝试这样做,但它似乎很乱:

    tempText = (TextView) findViewById( R.id.temperatureId );
    celsiusButton = (Button) findViewById( R.id.celsiusButton );
    celsiusButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_pressed_shape ) );
    celsiusButton.setClickable( false );

    celsiusButton.setOnClickListener( new OnClickListener() {
        public void onClick(View v) {
            if( hasRead ) {
                    celsiusButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_pressed_shape ) );
                    celsiusButton.setClickable( false );
                    fahrenheitButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_unpressed_shape ) );
                    fahrenheitButton.setClickable( true );
                    temperature = ( ( ( temperature - 32 ) * 5 …
Run Code Online (Sandbox Code Playgroud)

xml android button

12
推荐指数
2
解决办法
4万
查看次数

使用Javascript或AngularJS控制或禁用浏览器后退按钮

使用Javascript或AngularJS控制或禁用浏览器后退按钮

在这里我不是问一个问题,但我想展示如何使用AngularJS或甚至使用Javascript来禁用和控制浏览器的后退按钮的解决方案

javascript browser button back angularjs

12
推荐指数
1
解决办法
3万
查看次数

如何在Xcode中获取所有系统图标

我希望能够使用此处列出的相机开关图标而不是普通的开关图标. https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/BarIcons.html

但是在我的条形按钮项下的Xcode中它似乎没有列出? 在此输入图像描述

我明白我可能会遗漏一些明显的东西.有人能帮忙吗?

xcode button ios swift

12
推荐指数
1
解决办法
2万
查看次数

Xamarin.forms XAML圆形按钮

我正在尝试在我的Xamarin.Forms应用程序中放置一个圆形Button ,但我不能这样做.

我在按钮上阅读了一些关于自定义控制器的内容,但是我没有在Xamarin.forms中找到任何关于圆形按钮的文档.

有谁知道怎么做?我只是建立一个Android和iOS应用.

button xamarin xamarin.forms

12
推荐指数
2
解决办法
3万
查看次数

如果第一次没有运行,如何让应用程序转到另一个页面

我有RegisterPage和LoginPage.当应用程序运行时,它将检查应用程序是否是第一次运行RegisterPage.如果它是第一次运行并且button未单击保存,则它将进入RegisterPage.如果它第二次运行但是从不点击保存按钮,它也会保留RegisterPage.否则就会去LoginPage.

这是我更新的代码

寄存器

appGetFirstTimeRun();
boolean clicked=false;

 buttonSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                clicked=true;
                int appCurrentBuildVersion = BuildConfig.VERSION_CODE;
                SharedPreferences appPreferences = getSharedPreferences("MyAPP", 0);
                appPreferences.edit().putInt("app_second_time",
                        appCurrentBuildVersion).apply();
                String name = editTextName.getText().toString();
                String pass = editTextPassword.getText().toString();
                String confirm = editTextConfirm.getText().toString();
                if ((editTextName.getText().toString().trim().length() == 0) || (editTextPassword.getText().toString().trim().length() == 0) || (editTextConfirm.getText().toString().trim().length() == 0)) {
                    Toast.makeText(getApplicationContext(), "Field cannot be null", Toast.LENGTH_LONG).show();
                } 
                else
                 {
                      insertData(name, pass, imageUri); // insert …
Run Code Online (Sandbox Code Playgroud)

android button sharedpreferences

12
推荐指数
1
解决办法
369
查看次数

Segue和Button以编程方式迅捷

我正在使用iCarousel,我必须创建自己的按钮.我想将编程按钮中的数据传递给另一个视图,但我没有segue标识符,因为我以编程方式创建了按钮.我不知道是否可以通过编程方式创建segue的标识符.

button.addTarget(self, action: #selector(buttonAction3), for: .touchUpInside)
        button.setTitle("\(titulos[index])", for: .normal)
        tempView.addSubview(button)
        let myImage = UIImage(named: "modo4.png") as UIImage?
        button.setImage(myImage, for: .normal)

let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "modo") as! Modo1ViewController
self.present(viewController, animated: false, completion: nil)

if segue.identifier == "" {
        if let destination = segue.destination as? Modo1ViewController {
            destination.nomb = nombres
        }

    }
Run Code Online (Sandbox Code Playgroud)

button segue programmatically-created swift

12
推荐指数
1
解决办法
9102
查看次数