我正在尝试为android中的单选按钮实现自定义图标.即我希望单选按钮图标是我自己选择的一个.我可以使用android:button单选按钮内的属性来做到这一点,但我没有在用户单击它时如何定义它.在我的应用程序中,当用户点击它没有任何反应.我也在这里遵循了这个指南.
I have 2 images :
A. tire.png (When the radio button is not clicked)
B. tireinvert.png (When the radio button is clicked)
Run Code Online (Sandbox Code Playgroud)
我的RadioButton.xml文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.techfrk.customizeradiobutton.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<RadioGroup
android:id="@+id/newexprgrp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/tvllocrbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp"
android:text="Travelling Expense (Local)"
/>
<RadioButton
android:id="@+id/tvloutrbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:text="Travelling Expense (Outstation)"
/>
<RadioButton
android:id="@+id/phnexprbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:text="Phone Expense" …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的活动实现自定义适配器,该适配器将从两个ArrayList填充listview。但是,我对下一步该怎么办感到困惑?这是我的代码:
public class Offers extends Activity
{
ListView latesttrans;
Boolean flagValue = false;
ArrayList<String> listItems = new ArrayList<String>();
ArrayList<String> listAddress = new ArrayList<String>();
String[] addr;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_offers);
latesttrans = (ListView) findViewById(R.id.listView1);
Uri latesttransuri = Uri.parse("content://sms/inbox");
Cursor latesttranscursor = getContentResolver().query(latesttransuri, new String[]{"_id","address","date","body"}, null, null, null);
if(flagValue == false)
{
latesttranscursor.moveToFirst();
flagValue = true;
}
String address = null,body = null;
int i=0;
while(latesttranscursor.moveToNext())
{
address=latesttranscursor.getString(1);
long date = latesttranscursor.getLong(2);
String sdate = millisToDate(date);
body = …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的活动实现executeUpdate查询.但是我收到此错误:
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.techfrk.fetchinboxsms.Database_CustomTransaction.executeUpdate(java.lang.String)' on a null object reference
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
public class AddTransaction extends Activity implements OnItemSelectedListener, View.OnClickListener, OnItemClickListener
{
DateFormat formate = DateFormat.getDateInstance();
Calendar calendar = Calendar.getInstance();
ImageButton imgbtn_personal,imgbtn_debitCredit,imgbtn_transferAnother,imgbtn_incomeExpense,calendarimg;
Button dialogButton;
Database_CustomTransaction mydb1;
Boolean personal_flag=true, debitCredit_flag=true, transferAccount=true, incomeExpense=true;
String transaction_type = "No type selected !";
public static final String list_prefs = "PreferencesFile";
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_transaction);
imgbtn_personal = (ImageButton) findViewById(R.id.personal_business);
imgbtn_debitCredit = (ImageButton) findViewById(R.id.debit_credit_refund);
imgbtn_transferAnother = (ImageButton) findViewById(R.id.transfer_another_acc);
imgbtn_incomeExpense = …Run Code Online (Sandbox Code Playgroud) android ×3
arraylist ×1
baseadapter ×1
database ×1
listview ×1
radio-button ×1
sql ×1
sqlite ×1