当列表为空时,我想Button在下面添加一个像这样ListView的setEmptyView()方法.
Android中是否有内置样式?因为我注意到一些应用程序使用完全相同的Button样式.
我是Android开发的新手,我正在阅读创建自定义按钮的代码,告诉你没有时间你点击按钮.代码如下:
package com.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class HelloWorldActivity extends Activity implements View.OnClickListener {
Button button;
int touchCount;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
button=new Button(this);
button.setText("Click Me");
button.setOnClickListener(this);
setContentView(button);
}
public void onCLick(View v)
{
touchCount++;
button.setText("touched me"+touchCount+"time(s)");
}
}
Run Code Online (Sandbox Code Playgroud)
错误 :
The type HelloWorldActivity must implement the inherited abstract method View.OnClickListener.onClick(View) - Breakpoint:HelloWorldActivity
Run Code Online (Sandbox Code Playgroud)
我查看了几个网站并尝试了一些但没有任何效果.请帮帮我.谢谢.
我有一个工具按钮和一个分配给它的动作.但是该操作没有on click事件,没有单击代码.因此按钮被禁用,如何更改它以启用?
谢谢!
我一直在手动设置每个按钮的事件,但我如何概括呢?
我想我可以覆盖ButtonBase,但我该怎么做?我是一个相对较新的C#程序员,我需要这个,因为我正在模拟一个真实的设备,所以我需要更改光标,以便用户知道他们可以点击的位置.
我正试图从我的活动中启动我的应用程序在Android市场的页面.我是新手,也许我正在做错编码这是我在note.class中写的
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
public class Note extends Activity{
WebView mWebView;
WebView tWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.note);
mWebView = (WebView) findViewById(R.id.webview);
String text = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>" + "<p align=\"justify\">"
+ getString(R.string.fulldescription)+ "</p> " + "</body></html>";
mWebView.loadData(text, "text/html", "utf-8");
//seconda webview dove dormire-mangiare
tWebView = (WebView) findViewById(R.id.webview2);
String text2 = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; …Run Code Online (Sandbox Code Playgroud) 我目前有一个自定义Dialog类,它扩展了DialogPreference(当然它是PreferenceScreen的一部分).
此对话框具有处理保存和取消的自定义按钮.因此,我想摆脱标准的"积极"和"消极"按钮.
尝试使用AlertDialog getButton方法但没有成功.
我有一个按钮,我不希望可以点击直到一定的时间运行(比如5秒?)我尝试创建这样的线程
continueButtonThread = new Thread()
{
@Override
public void run()
{
try {
synchronized(this){
wait(5000);
}
}
catch(InterruptedException ex){
}
continueButton.setVisibility(0);
}
};
continueButtonThread.start();
Run Code Online (Sandbox Code Playgroud)
但是我不能在不同的线程中修改按钮的setVisibility属性.这是LogCat的错误:
10-02 14:35:05.908:ERROR/AndroidRuntime(14400):android.view.ViewRoot $ CalledFromWrongThreadException:只有创建视图层次结构的原始线程才能触及其视图.
还有其他方法来解决这个问题吗?
快速问题,通过按钮调用ruby方法的最佳方法是什么?目前,该按钮只会调用JS函数,但我需要它执行Ruby方法.
基本上,该按钮必须将Excel电子表格与我的数据库进行比较,并在另一页面上显示表格中的差异.如何在不生成新模型的情况下创建该页面?抱歉这个愚蠢的问题,但我只是坚持惯例,因此我不确定如何创建新页面.
在此先感谢您的帮助
我想在文本中放一个按钮,如下所示:
some text1 [button] some text2.
Run Code Online (Sandbox Code Playgroud)
但是,如果我放置表单和输入,换行符会在我的按钮之前和之后发生,如下所示:
some text1
[button]
some text2
Run Code Online (Sandbox Code Playgroud)
我知道我可以用桌子来做这件事,但我想避免它.有没有基于CSS的解决方案来做到这一点?不幸的是,我不能修改HTML代码,所以我必须在生成的HTML(由其他软件完成)中"注入"那个小的表单语句(输入类型提交,以及一些隐藏的输入标记),所以它将是很难重新格式化,使用表格等
将表单/输入标签放在"p"标签之间的文本中是否合法?
提前致谢.
我正在使用API 8进行编码.
我需要从View中获取坐标X和Y,并将它们设置为新Button的坐标.
我试过不同的方法但没有任何作用......
setX和getX方法仅适用于api级别11,我需要一种方法在API8上执行此操作.
这是我的方法,允许创建一个按钮的可拖动副本(此副本是一个imageview,当我删除它成为一个新按钮)
public boolean dragCopy(View view, MotionEvent me, Button bt){
int x,y,w,h,id,t,l;
int cont=-1;
int coord[] = new int[2];
bt2=new Button(this);
id = bt.getId();
bt2.setId(id);
Resources res = getResources();
cont = FindCont(bt, vector);
dr = getLetter(bt, dr, res, vector, cont);
w=dr.getIntrinsicWidth();
h=dr.getIntrinsicHeight();
if (me.getAction() == MotionEvent.ACTION_DOWN) {
//clicked on the button. DRAG START
status = START_DRAGGING;
image = new ImageView(this);
//set image drawable
image.setImageDrawable(dr);
image.setPadding((int)bt.getLeft(),(int)bt.getTop(), 0, 0);
layout.addView(image, params);
}
if (me.getAction() == MotionEvent.ACTION_UP) {
//button …Run Code Online (Sandbox Code Playgroud)