[android-developers] Disabling records in a List View

2010-04-18 Thread Prathamesh Shetye
I have a list view which is populated via records from the database.
Now i have to make some records visible but unavailable for selection,
how can i achieve that?

here's my code

public class SomeClass extends ListActivity {

private static ListString products;

private DataHelper dh;

public void onCreate(Bundle savedInstanceState) {

dh = new DataHelper(this);

products = dh.GetMyProducts();  /* Returns a ListString*/

super.onCreate(savedInstanceState);

setListAdapter(new ArrayAdapterString(this, 
R.layout.myproducts,
products));

ListView lv = getListView();
lv.setTextFilterEnabled(true);

lv.setOnItemClickListener(
new OnItemClickListener() {
@Override
public void onItemClick(AdapterView? arg0, 
View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), 
((TextView)
arg1).getText(),
  Toast.LENGTH_SHORT).show();
}
}
);
}
}


The layout file myproducts.xml is as follows

?xml version=1.0 encoding=utf-8?
TextView   xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=wrap_content
android:padding=10dp
android:textSize=16sp
/TextView

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Disabling records in a List View

2010-04-18 Thread Prathamesh Shetye
Thanks Mark, I'll try it out.

Cheers!

On Apr 18, 6:20 pm, Mark Murphy mmur...@commonsware.com wrote:
 Prathamesh Shetye wrote:
  I have a list view which is populated via records from the database.
  Now i have to make some records visible but unavailable for selection,
  how can i achieve that?

 Step #1: Create your own subclass of ArrayAdapter

 Step #2: Override areAllItemsEnabled() in that subclass to return false

 Step #3: Override isItemEnabled() in that subclass to return true for
 the enabled positions and false for the disabled positions

 Note that disabled rows do not get dividers around them. Dividers only
 separate a pair of enabled rows.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Warescription: Three Android Books, Plus Updates, One Low Price!

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Disabling records in a List View

2010-04-18 Thread Prathamesh Shetye
Hi Mark, Here's what I did

My Existing Class extending ListActivity

/
***/
public class LifeProducts extends ListActivity {

private static ListString products;
private static ListString actives;

private DataHelper dh;
private ListMyProducts ips;

public void onCreate(Bundle savedInstanceState) {

dh = new DataHelper(this);
ips = dh.GetMyProducts();

products = new ArrayListString();
actives = new ArrayListString();

for(MyProducts ip : ips){
products.add(ip.name);

if (ip.active == 0)
actives.add(N);
else
actives.add(Y);
}

super.onCreate(savedInstanceState);

ProductAdapterString pas = new ProductAdapterString(this,
R.layout.life_products, products);
pas.setActiveList(actives);
setListAdapter(pas);

ListView lv = getListView();
lv.setTextFilterEnabled(true);

lv.setOnItemClickListener(
new OnItemClickListener() {
@Override
public void onItemClick(AdapterView? arg0, 
View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), 
((TextView)
arg1).getText(),
  Toast.LENGTH_SHORT).show();
}
}
);
}
}

and here's how i overloaded the ArrayAdapter
/
***/
@SuppressWarnings({ unchecked, hiding })
public class ProductAdapterString extends ArrayAdapter{

public ProductAdapter(Context context, int textViewResourceId, List
objects) {
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
}

public ListString actives;

public void setActiveList(ListString act){
actives = act;
}

@Override
public boolean areAllItemsEnabled(){
return false;
}

@Override
public boolean isEnabled(int position){
for (String s : actives){
if (s == Y)
return true;
else
return false;
}
return true;
}
}
/
***/
Now my Database has 8 records, which are to be displayed
I am not getting any error but the my output just contains the last
records displayed 8 times

what am i doing wrong??

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Disabling records in a List View

2010-04-18 Thread Prathamesh Shetye
never mind, solved it, cheers mate!

On Apr 18, 8:26 pm, Prathamesh Shetye prathamesh.she...@gmail.com
wrote:
 Hi Mark, Here's what I did

 My Existing Class extending ListActivity

 /
 *** 
 /
 public class LifeProducts extends ListActivity {

         private static ListString products;
         private static ListString actives;

         private DataHelper dh;
         private ListMyProducts ips;

         public void onCreate(Bundle savedInstanceState) {

                 dh = new DataHelper(this);
                 ips = dh.GetMyProducts();

                 products = new ArrayListString();
                 actives = new ArrayListString();

                 for(MyProducts ip : ips){
                         products.add(ip.name);

                         if (ip.active == 0)
                                 actives.add(N);
                         else
                                 actives.add(Y);
                 }

                 super.onCreate(savedInstanceState);

                 ProductAdapterString pas = new ProductAdapterString(this,
 R.layout.life_products, products);
                 pas.setActiveList(actives);
                 setListAdapter(pas);

                 ListView lv = getListView();
                 lv.setTextFilterEnabled(true);

                 lv.setOnItemClickListener(
                         new OnItemClickListener() {
                                 @Override
                                 public void onItemClick(AdapterView? arg0, 
 View arg1, int arg2,
                                                 long arg3) {
                                         // TODO Auto-generated method stub
                                         
 Toast.makeText(getApplicationContext(), ((TextView)
 arg1).getText(),
                                                   Toast.LENGTH_SHORT).show();
                                 }
                         }
                 );
         }

 }

 and here's how i overloaded the ArrayAdapter
 /
 *** 
 /
 @SuppressWarnings({ unchecked, hiding })
 public class ProductAdapterString extends ArrayAdapter{

         public ProductAdapter(Context context, int textViewResourceId, List
 objects) {
                 super(context, textViewResourceId, objects);
                 // TODO Auto-generated constructor stub
         }

         public ListString actives;

         public void setActiveList(ListString act){
                 actives = act;
         }

         @Override
         public boolean areAllItemsEnabled(){
                 return false;
         }

         @Override
         public boolean isEnabled(int position){
                 for (String s : actives){
                         if (s == Y)
                                 return true;
                         else
                                 return false;
                 }
                 return true;
         }}

 /
 *** 
 /
 Now my Database has 8 records, which are to be displayed
 I am not getting any error but the my output just contains the last
 records displayed 8 times

 what am i doing wrong??

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] About how to make new buttons in a row?

2010-04-13 Thread Prathamesh Shetye
Add a TableRow before the buttons

Sent from my Android (on Moto Milestone)

On Apr 12, 2010 11:18 AM, xlshe dianyuangua...@gmail.com wrote:

Hi all,

I want to create three button on the layout. But the default align of
the buttons is in a column like:
Button1
Button2
Button3
But I want to the three buttons align in a row in order to save space.
The align of the three buttons I need is :
Button1  Botton2  Botton3

Would you please tell me how to do that? Thank you very much!

--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: About how to make new buttons in a row?

2010-04-13 Thread Prathamesh Shetye
try this
TableLayout
 TableRow
//Add Your Buttons Here
 /TableRow
/TableLayout

On Apr 12, 10:47 am, xlshe dianyuangua...@gmail.com wrote:
 Hi all,

 I want to create three button on the layout. But the default align of
 the buttons is in a column like:
 Button1
 Button2
 Button3
 But I want to the three buttons align in a row in order to save space.
 The align of the three buttons I need is :
 Button1  Botton2  Botton3

 Would you please tell me how to do that? Thank you very much!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.


[android-developers] Android App Presentation

2010-04-13 Thread Prathamesh Shetye
I wanted to make a video presentation of my android application. i
know i can make the presentation by holding a camcorder in front of
the screen and give walkthrough the application. But is there any
other way this can be done, something on the lines of JingProject for
windows wherein you can record your activities on your screen in a
video.

is there a tool that can help me achieve the same on my android device
(Motorola Milestone)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.