Hi Experts,
I am new to Java as well as Android developement. Please help in the
very fundamental issue.the think is i just want to include checkbox in
Listview.How to do it @ programetical or @ Design time.I am using
eclipse for the dev. here i extented List Activity.
I am trying the following Code.
public class FrmOrders extends ListActivity
{
ListView listView;
String [] strArray;
@Override
public void onCreate(Bundle bndl)
{
super.onCreate(bndl);
setContentView(R.layout.orders);
DBAdapter dbObj = new DBAdapter(FrmOrders.this);
try
{
dbObj.open();
Cursor c = dbObj.getAllSalesOrders();
if (c.moveToFirst())
{
int count = c.getCount();
strArray = new String[count];
for(int i=0;i<count;i++)
{
strArray[i] = "Customer: "+c.getString(2);
c.moveToNext();
}
}
dbObj.close();
listView = (ListView)findViewById(R.id.ListView01);
listView.setItemsCanFocus(false);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
ArrayAdapter<String> listViewArrayAdapter = new ArrayAdapter<String>
(FrmOrders.this,
android.R.layout.simple_list_item_multiple_choice, strArray);
listView.setAdapter(listViewArrayAdapter);
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> adapterview, View arg1,
int arg2, long arg3)
{
String str = String.valueOf(adapterview.getSelectedItem());
Toast .makeText(getBaseContext(),String.valueOf(str.length
()), Toast.LENGTH_LONG).show();
}
});
}
catch (Exception e)
{
Toast .makeText(getBaseContext(),DBAdapter.strException ,
Toast.LENGTH_LONG).show();
Toast.makeText(getBaseContext(),e.toString(),Toast.LENGTH_LONG).show
();
}
}
Thanks in Advance.
Vamsi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---