Re: [android-beginners] Re: custom listview add button above listeview
Sorry for the delay in responding. On Fri, Jul 30, 2010 at 10:01 PM, calmchess wrote: > yes i think this does what i'm looking for do I need to write it from > scratch or can i modify this code to suite my needs and use it? It is licensed under the Apache License 2.0. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: custom listview add button above listeview
Thankyou so much I was pulling hair out trying to google this all the tutorials out there just show how to populate the customlist and thats all. You went 1 step further and now i have what i need for my archive...you sir are a patron. -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: custom listview add button above listeview
yes i think this does what i'm looking for do I need to write it from scratch or can i modify this code to suite my needs and use it? -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Re: custom listview add button above listeview
On Fri, Jul 30, 2010 at 9:25 PM, calmchess wrote: > and now i think we are at the root of my problem...how do > i seperate the row from the container?? Well, your source code got cut off, so it is difficult to answer. Somewhere, your Activity is calling setContentView(). Ideally, particularly for this case, setContentView() is passed a resource ID pointing to a layout resource (e.g., R.layout.main). This is the layout file that Nick demonstrated and Kostya referred to. That layout for your whole activity needs to have your Button and your ListView, wrapped in a RelativeLayout or LinearLayout. Here is an example project, albeit one with a TextView instead of a Button above the ListView: http://github.com/commonsguy/cw-android/tree/master/Selection/List/ Here is a variation on that sample project, using a custom ListAdapter: http://github.com/commonsguy/cw-android/tree/master/FancyLists/Recycling/ -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 2.9 Available! -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: custom listview add button above listeview
and now i think we are at the root of my problem...how do i seperate the row from the container?? because right now its merging both togeather I've been working on this for days if you could help me seperate the two i'd appriciate it. -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Re: custom listview add button above listeview
On Fri, Jul 30, 2010 at 9:16 PM, calmchess wrote: > for the billionth time i'm useing a CUSTOM LISTVIEW it inflates the > xml Which has nothing to do with anything. < and getview gets called as many times as there is items in the > array...if you put a button in the xml no matter what way you format > the XML the button gets displayed multiple times not 1 time multiple > times The XML that was supplied is not for the *row*. It is for the *container around the ListView*. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 2.9 Available! -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: custom listview add button above listeview
for the billionth time i'm useing a CUSTOM LISTVIEW it inflates the
xml and getview gets called as many times as there is items in the
array...if you put a button in the xml no matter what way you format
the XML the button gets displayed multiple times not 1 time multiple
times .no matter how you display the XML here is the code
modify it and give it a try and if your way works then i'll eat dirt.
package com.cuslistview;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
public class customlistview extends Activity implements
OnClickListener{
ListView l1;
private static class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private ArrayList> ret=null;
public EfficientAdapter(Context context) {
Sax sax1 = new Sax();
try {
ret = sax1.SaxIni();
} catch (Exception e) {
e.printStackTrace();
}
mInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return ret.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertview, ViewGroup
parent) {
ViewHolder holder;
if (convertview == null) {
convertview = mInflater.inflate(R.layout.main,
parent,false);
holder = new ViewHolder();
//holder.text = (TextView)
convertview.findViewById(R.id.TextView01);
holder.text0 = (TextView)
convertview.findViewById(R.id.TextView0);
holder.text1 = (TextView)
convertview.findViewById(R.id.TextView1);
holder.text2 = (TextView)
convertview.findViewById(R.id.TextView2);
convertview.setTag(holder);
} else {
holder = (ViewHolder) convertview.getTag();
}
//holder.text.setText(ret.get(position) );
holder.text0.setText(ret.get(0).get(position));
holder.text1.setText(ret.get(1).get(position));
holder.text2.setText(ret.get(2).get(position));
//convertview.setBackgroundColor((position & 1) == 1 ?
Color.WHITE : Color.LTGRAY);
convertview.setBackgroundColor((position & 1) == 1 ?
Color.LTGRAY : Color.GREEN);
return convertview;
}
static class ViewHolder {
TextView text0;
TextView text1;
TextView text2;
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
Button getdata_btn;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//getdata_btn = new Button(this);
//getdata_btn.setWidth(5);
//getdata_btn.setHeight(5);
//getdata_btn.setText("Press To Update");
l1 = (ListView) findViewById(R.id.ListView01);
//getdata_btn.setOnClickListener(this);
ColorDrawable divcolor = new
ColorDrawable(Color.RED);
//l1.addHeaderView(getdata_btn);
l1.setDivider(divcolor);
l1.setDividerHeight(2);
//layout1.addView(l1);
l1.setAdapter(new EfficientAdapter(this));
}
@Override
public void onClick(View v) {
l1.setAdapter(new EfficientAdapter(this));
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Ove
Re: [android-beginners] Re: custom listview add button above listeview
On Fri, Jul 30, 2010 at 8:55 PM, calmchess wrote: > I'm sorry i didn't try your code this isn't somthing that can be fixed > by formatting XML Yes, it can be. What you say you want is precisely what Nick and Kostya have supplied in the answers. > the button is always inside the listview no matter > what i do although yours came close to doing what i want.i want a > button outside the listview and doesn't get highlighted by the list > viewthankyou for your time. Which is precisely what Nick and Kostya have supplied in the answers. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 2.9 Available! -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: custom listview add button above listeview
I'm sorry i didn't try your code this isn't somthing that can be fixed by formatting XML the button is always inside the listview no matter what i do although yours came close to doing what i want.i want a button outside the listview and doesn't get highlighted by the list viewthankyou for your time. -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Re: custom listview add button above listeview
How can you still be having an issue? I literally gave you the XML that you
need to accomplish what you're trying to do.
On Fri, Jul 30, 2010 at 8:24 AM, Kostya Vasilyev wrote:
> Declare the button in the activity's layout xml, above the ListView.
>
> -- Kostya
>
> 30.07.2010 19:20, calmchess пишет:
>
> I'm useing custom list view.which inflates the view..if you put a
>> button in the XML it will put a button in each cell of the list view
>> i only want 1 button above the list view here is some more code to
>> make it clear.
>>
>> public class customlistview extends Activity implements
>> OnClickListener{
>>ListView l1;
>> private static class EfficientAdapter extends BaseAdapter {
>>private LayoutInflater mInflater;
>>private ArrayList> ret=null;
>>
>> public EfficientAdapter(Context context) {
>> Sax sax1 = new Sax();
>> try {
>>ret = sax1.SaxIni();
>>} catch (Exception e) {
>>
>>e.printStackTrace();
>>}
>>
>>
>> mInflater = LayoutInflater.from(context);
>>
>>
>>
>> }
>>
>>
>>
>
>
> --
> Kostya Vasilev -- WiFi Manager + pretty widget --
> http://kmansoft.wordpress.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>
--
//Nick Richardson
//[email protected]
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Re: custom listview add button above listeview
Declare the button in the activity's layout xml, above the ListView.
-- Kostya
30.07.2010 19:20, calmchess пишет:
I'm useing custom list view.which inflates the view..if you put a
button in the XML it will put a button in each cell of the list view
i only want 1 button above the list view here is some more code to
make it clear.
public class customlistview extends Activity implements
OnClickListener{
ListView l1;
private static class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private ArrayList> ret=null;
public EfficientAdapter(Context context) {
Sax sax1 = new Sax();
try {
ret = sax1.SaxIni();
} catch (Exception e) {
e.printStackTrace();
}
mInflater = LayoutInflater.from(context);
}
--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: custom listview add button above listeview
I'm useing custom list view.which inflates the view..if you put a
button in the XML it will put a button in each cell of the list view
i only want 1 button above the list view here is some more code to
make it clear.
public class customlistview extends Activity implements
OnClickListener{
ListView l1;
private static class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private ArrayList> ret=null;
public EfficientAdapter(Context context) {
Sax sax1 = new Sax();
try {
ret = sax1.SaxIni();
} catch (Exception e) {
e.printStackTrace();
}
mInflater = LayoutInflater.from(context);
}
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

