我有一个Autocompletetextview字段.问题是在纵向视图中,除了我的阵列显示顶部的建议之外,下面会弹出一个条形图,其中包含来自字典的建议.我似乎无法弄清楚如何禁用它们.
即时开发一个应用程序,其中gridview包含按钮列表...
当我在gridview中放置图像而不是按钮然后onItemClickEvent被解雇..但如果我在gridView中放置按钮然后点击事件没有被调用...我不知道是什么问题...即使我没有得到例外..
这是我的代码......
public class MainMenu extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GridView gridview = (GridView) findViewById(R.id.mainMenu);
gridview.setAdapter(new ImageAdapter(this));
gridview.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
Toast.makeText(MainMenu.this, "hello" + position, Toast.LENGTH_SHORT).show();
}
});
}
//inner class for adapter
class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c)
{
mContext = c;
}
public int getCount() {
return …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一些单选按钮并动态添加一个RadioGroup.当我使用LayoutInflater方法拉入xml并将其添加到当前视图时,一切正常.出现正确的单选按钮.
但是,当我尝试将LayoutInflater.inflate的View转换为RadioButton(因此我可以使用setText)时,我得到一个强制关闭java.lang.ClassCastException.
for (int i = 0; i < options.length(); i++) {
JSONObject option = options.getJSONObject(i);
View option_view = vi.inflate(R.layout.poll_option, radio_group, true);
option_view.setId(i);
RadioButton rb = (RadioButton) option_view.findViewById(i);
rb.setText(option.getString("response"));
}
Run Code Online (Sandbox Code Playgroud)
poll_option.xml:
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
android:text="RadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud) 我已经制作了ArrayList并通过coading逐个添加值.我能够看到整个arrayList如下面的代码:
// TO DISPLAY DATA
for(int j=0;j<tempEmployerList.size();j++)
{
System.out.println("================ Employee: "+(j+1)+"======================");
m = new Employer();
m=tempEmployerList.get(j);
//System.out.println("TaxCodeHeading: "+(j+1)+" = "+m.getOrderName());
System.out.println("TaxCode: "+(j+1)+" = "+m.getTaxcode());
System.out.println("PayPeriod: "+(j+1)+" = "+m.getPayPeriod());
System.out.println("Frequency: "+(j+1)+" = "+m.getPayFrequency());
System.out.println("Salary/Wage: "+(j+1)+" = "+m.getSalaryWage());
System.out.println("NetGross Amount: "+(j+1)+" = "+m.getNetGrossAmount());
System.out.println("KiwiSaverMember: "+(j+1)+" = "+m.getKiwiSaverMember());
System.out.println("Employee Deduction: "+(j+1)+" = "+m.getEmployeeDeduction());
System.out.println("Complying Fund Member: "+(j+1)+" = "+m.getComplyingFundMember());
System.out.println("Fund Contribution: "+(j+1)+" = "+m.getFundContribution());
System.out.println("ESCT Tax Rate: "+(j+1)+" = "+m.getESCTTaxRate());
System.out.println("Child Support Deduction: "+(j+1)+" = "+m.getChildSupportDeduction());
System.out.println("Payroll giving Donation: "+(j+1)+" = "+m.getPayrollDonation());
} …Run Code Online (Sandbox Code Playgroud) 我是所有小部件工作人员的新手,所以我试图制作一个简单的,只显示一个名称.我已经阅读了几个教程,但我无法改变大小!这不是我想在运行时尝试更改它,我改变了小部件提供程序的大小,它不会改变!
对此有任何帮助!
我的代码是:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/widget"
android:minHeight="146dp"
android:minWidth="146dp"
android:updatePeriodMillis="10000" />
Run Code Online (Sandbox Code Playgroud) 在下图中是我的列表视图下方和我的按钮上方的灰色区域.我希望该区域具有与列表相同的背景颜色(黑色).
对我来说似乎很奇怪的是,在模拟器中它是黑色的,但在我的手机上,它是灰色的.

我已经尝试设置布局,列表和cachecolorhint的背景颜色......无论如何,它都保持灰色.
目前的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000" >
<TextView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="27dp"
android:layout_alignParentTop="true"
android:layout_gravity="center|center_vertical"
android:gravity="center"
android:textColor="#00ccff"
android:textSize="20dp" />
<TextView
android:id="@+id/horizontalline"
android:layout_width="match_parent"
android:layout_height="2dip"
android:layout_below="@id/header"
android:background="#8b8b8b"
android:paddingBottom="2dip"
android:paddingTop="2dip" />
<Button
android:id="@+id/AddButton"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:gravity="center|top"
android:textSize="12dp" >
</Button>
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@id/horizontalline"
android:background="#000000"
android:cacheColorHint="#000000"
android:layout_above="@id/AddButton"
android:drawSelectorOnTop="false"
android:listSelector="@android:color/transparent" />
<TextView
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/header"
android:gravity="center" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
任何帮助赞赏.
编辑
要清楚,当列表填满屏幕时,我对列表没有任何问题,只有少数几个项目没有填满屏幕我得到这个灰色背景...我更喜欢它是相同的黑色背景列表.
什么是这个选项菜单按钮以及我如何摆脱它?
见图

我有两个旋转器,一个带
android:spinnerMode="dialog"
Run Code Online (Sandbox Code Playgroud)
和另一个
android:spinnerMode="dropdown"
Run Code Online (Sandbox Code Playgroud)
现在,当我点击任一个微调器时,我发现它们之间没有区别.
我有一个ImageButton,它在单击时执行长时间运行的操作.所以我试图做的不成功的是在onClick调用开始时更改图像并在结束时将其更改回来.
我已经尝试了下面的代码,但我发现在onClick完成后android重绘了按钮图像,所以没用.
如果可能的话,我也愿意采取其他方式来做到这一点.
下面是我使用的代码片段.Thread.sleep表示长时间运行的操作.我想在执行到达睡眠状态时看到图像更改,而不是在onClick完成后.
btnTest = (ImageButton) findViewById(R.id.btnTest);
btnTest.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("start");
btnTest.setImageResource(R.drawable.add);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
System.out.println("end");
btnTest.setImageResource(R.drawable.del);
}
});
Run Code Online (Sandbox Code Playgroud) 我有一个带有TextView的主屏幕小部件:
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="none"
android:singleLine="true"
android:textStyle="bold" />
Run Code Online (Sandbox Code Playgroud)
我需要得到这篇文章的大小.我试图获取默认TextView的大小文本,如下所示:
TextView defaultTextView = new TextView(context);
float sourceTextSize = defaultTextView.getTextSize();
Run Code Online (Sandbox Code Playgroud)
而sourceTextSize包含21.但这是错误的值,因为如果我使用remoteViews.setFloat(R.id.textView, "setTextSize", 21)它,它会使我的文本更大.
如何在窗口小部件上获取TextView的默认文本大小?