标签: button

ListView无法响应Android中的点击事件

我有一个自定义ListView项目如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" 
    android:gravity="center_vertical" 
    android:paddingTop="2dp"
    android:paddingBottom="2dp"
    android:background="@android:color/transparent">

    <ImageView
        android:id="@+id/profile_picture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/mr_unknown" 
        android:contentDescription="@string/profile_picture_description"
        android:paddingRight="3dp"/>

    <TextView
        android:id="@+id/real_life_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="@style/FriendListText"/>
    <Button 
        android:id="@+id/ping_friend"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Ping Friend"
        />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

在这个ListView中使用:

<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="fill_parent"
    android:orientation="vertical"
    android:background="@color/white"
    tools:context=".FriendListActivity" >

    <ListView
        android:id="@+id/friend_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fastScrollEnabled="true"
        android:smoothScrollbar="false"
        style="@style/ListViewStyle" >
    </ListView>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

现在我希望当任何列表项上点击Ping Friend按钮时它应该显示AlertDialog.我用过这段代码......

friendListAdapter = new FriendListAdapter(FriendListActivity.this, friends);
friendListView = (ListView) findViewById(R.id.friend_list);
friendListView.setAdapter(friendListAdapter);           

downloadFriends_async(); //This method downloads all the *friends* into ListView …
Run Code Online (Sandbox Code Playgroud)

java android button android-listview onclicklistener

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

如何在Java中编写DropDownButton代码

我需要在Java中创建这样的按钮:

ContextMenuButton

您可以单击按钮的左侧部分进行常规按钮操作,然后单击右侧的箭头打开下拉菜单.

是否有可能在java中创建这样的东西?谢谢!

java button drop-down-menu

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

android中的按钮高亮显示

我的应用程序的布局文件中的按钮有以下代码

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:text="Start updating" />
Run Code Online (Sandbox Code Playgroud)

默认情况下,按下按钮时,其高亮颜色为蓝色.如何将其更改为我想要的颜色?(我希望它是深红色的)

android colors button

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

用android app运行脚本

我有这个shell脚本:

#!system/bin/sh
while :
do
sync
echo 3> /proc/sys/vm/drop_caches
echo "Script is been launched"
sleep 30m
done
exit 0;
Run Code Online (Sandbox Code Playgroud)

我希望用Android应用程序运行此脚本.我现在已经创建了一个只有吐司的按钮.如何使用脚本(free.sh)并使用应用程序上的按钮启动它?或者有一个解决方案来重写java中的代码?谢谢

bash shell android button

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

asp.net mvc 4从控制器按钮调用方法

在我的控制器中,我有类AccountController,并在我有这个方法

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
    WebSecurity.Logout();
    return RedirectToAction("Index", "Home");
}
Run Code Online (Sandbox Code Playgroud)

在我的视图中,我有一个带有正文的cshtml页面和这部分代码

<form class="float_left" action="Controllers/AccountController" method="post">
    <button class="btn btn-inverse" title="Log out" type="submit">Log   Off</button>
</form>
Run Code Online (Sandbox Code Playgroud)

这不起作用,任何人都知道什么是问题或其他一些简单的解决方案?

asp.net-mvc button controllers asp.net-mvc-4

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

单击AngularJS中的Fire按钮

我想在输入中按Enter时触发按钮的单击事件,我发现使用AngularJS非常困难.

我的观点(简化,更新):

<!doctype html>
<html lang="en" ng:app="test">
    <head>
        <meta charset="utf-8" />
        <title>Test</title>
        <link rel="stylesheet" href="css/app.css" />
    </head>
    <body ng-controller="TestController">
        <button ng-click="onButton1Click()" class="btn1">Click Me</button>
        <button ng-click="onButton2Click()" class="btn2">Don't click me</button>
        <script src="lib/jquery/jquery.js"></script>
        <script src="lib/angular/angular.js"></script>
        <script src="js/testcontroller.js"></script>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我对此视图的控制器:

'use strict';

angular.module('test', [])
.controller('TestController', ['$scope',
    function($scope) {

        $scope.onButton1Click = function() {
            alert("Hello");
        }

        $scope.onButton2Click = function() {
            $('.btn2').click();
        }
}])
Run Code Online (Sandbox Code Playgroud)

我简化了所有代码.当我点击btn2时,我收到此错误

$申请已在进行中

不,我不能$scope.onButton1Click()直接打电话,我必须模拟btn1点击.

events input click button angularjs

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

如何将按钮字体设置为Marlett

我正在尝试将按钮字体设置为系统的Marlett字体.但是,虽然我手动设置了font-face,但使用了其他字体.此外,当我使用字体对话框为该按钮选择字体时,未列出Marlett.

为什么会这样?如何在.NET Windows窗体控件中使用Marlett字体?

c# fonts button truetype winforms

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

创建一个仅包含代码AS3的按钮

我觉得这样的东西存在,但我如何只在动作脚本3代码中创建一个按钮?我的意思是没有制作形状并将其转换为按钮符号或其他东西.它可能会更容易只在FlashDevelop中工作.

flash button actionscript-3

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

MVC3未终止字符串常量语法错误

我有以下代码,它给我一个语法错误 - 未终止的字符串常量.我已经匹配引号似乎无法发现问题.有任何想法吗?它工作正常,语法错误只是烦人.

  <input type="button" class="my-button" value="" name="back" onclick="location.href='@Url.Action(Model.Back.Step.ToString(), "MyController")'" />
Run Code Online (Sandbox Code Playgroud)

button url.action razor asp.net-mvc-3

6
推荐指数
2
解决办法
8820
查看次数

如何在Javascript中循环检查文档中的字符串?

我正在尝试创建一个搜索特定文本的代码,如果找到它将单击一个按钮.它需要不断检查字符串,但我正在努力找到一种方法来实现.我是一个完整的编码新手,所以任何帮助表示赞赏!:)

var findMe = [
    //Test
    'Hello!',
];

function findText() {
    var text = document.querySelector('div[id=BtnText]');

    for (var i = 0; i < findMe.length; i++) {
        if (BtnText.match(findMe[i])) {
            var btnDo = document.querySelector('input[type="submit"][value="Click!"]');
            if (btnDo) {
                btnDo.click();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript string loops button

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