last day (14 days later) » 

10:27 AM
1
A: Spinner - how to set border around drop down list?

Karthika PBfor custom border you can create an xml file inside drawable folder <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/white_overlay_8x" /> <corners android:radius="6dip" /> <stroke android:color="@col...

 
Error:(3, 27) No resource found that matches the given name (at 'color' with value '@color/white_overlay_8x').
 
@jomin_george94 please replace @color/white_overlay_8x' with some color available in your color.xml or atleast replace it with a color code like "#000000" .
 
I am sorry but now i get this error ; Error:(106, 41) String types not allowed (at 'background' with value 'R.drawable.file.xml').
It's fine I replaced it with this : android:background="@drawable/file"
I have done what you told me to do but no difference
the link I have added is a screenshot of what I see after following your suggestion
 
@jomin_george94 please tell me really what do you expect ? the above code can be customized with different colors and size.
 
Yeah sorry it was beause of my background colour. It works
 
10:27 AM
ok please accept the answer if it was useful
 
Can i quickly ask you something
 
yes
 
this is the image I get now
Is there anyway I could put a prompt
so that the user knows its a drop down list , also an arrow at the side ?
are you there ?
 
ys let me check i was away from my seat
 
oh okay sorry
 
10:34 AM
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
change the android.R.layout.simple_spinner_item with android.R.layout.simple_dropdown... or something i think it have a default arrow like drawable on right
 
but this will appear in all spinner rows.
 
its an arrow right
it doesn't work
 
yes i get tasks to go with custom spinner and so i never used it.But if you want to show arrow only at the top most item then you should go with a custom spinner
do you want to show the arrow only at top ?
 
yeah an arrow at the top left
and do you know the prompt why do you think that's not wrking ?? because I thought that's howyou display prompt
dropdown.setPrompt("Please select ");
 
10:41 AM
yes but prompt appears only when spinner expands isn't it?
 
sorry what do you mean?
my spinner does expand
so when I click on the spinner those items does show up
 
can you please show me the spinner which shows your prompt..
 
Spinner dropdown = (Spinner)findViewById(R.id.spinnerUpdateContactMethod);
String[] items = new String[]{"1", "2", "three"};
dropdown.setPrompt("Please select ");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items);
dropdown.setAdapter(adapter);
the setprompt doesn't show at all
 
I never used prompt because I always got to generate spinners with images or buttons like that..
 
hmm
How does that work ?
 
10:45 AM
it does not show man.That's the thing I was trying to convey
 
Its still spinner right ?
 
for this I have a not straight method
post your xml here i'll edit it
 
this is my spinner xml
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/spinnerUpdateContactMethod"
android:background="@drawable/file"
android:spinnerMode="dropdown"

android:layout_marginTop="15dp"
android:touchscreenBlocksFocus="false"
android:padding="10dp" />
                                                                                                                                       and inside the file.xml :
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFFFF" />
<corners android:radius="6dip" />
<stroke
android:color="#000000"
android:width="2dp" />

</shape>
 
<TextView
sorry wait pls
 
10:51 AM
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/dummytext"
android:background="@drawable/file"
android:text="Please select "
android:drawableRight="@drawable/arrow"

android:layout_marginTop="15dp"

android:padding="10dp" />

<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/spinnerUpdateContactMethod"
android:background="@drawable/file"
android:spinnerMode="dropdown"
android:visibility="gone"
android:layout_marginTop="15dp"
make the spinner to get visible only on click of textview
make textview invisible/gone then
do you have constant number of data in your array(will it change dynamically)?
 
I only would have two options within that spinner
 
ok inside the onclick of the dummy textview do 3 things
1) make textview setvisibility to gone
2) make spinner visible
 
so do i just do this
 
3) spinner.performClick();
 
findViewById(R.id.dummytext).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
findViewById(R.id.spinnerUpdateContactMethod).setVisibility(View.VISIBLE);
findViewById(R.id.update_selectacontactmethod).setVisibility(View.GONE);
}
});
 
10:56 AM
try
include spinner.performClick();
the only your spinner will expand
 
okay i will try that
yeah that worke
worked*
 
okk
:)
 
so how would I put the arrow
I am sorry but I just want to know if there is any way
 
android:drawableRight="@drawable/arrow"
you have this line in your textview right?
 
ohh yeah
sorry I just checked it
Thank You so much
now
:)
 
11:01 AM
include an arrow.png/jpg in drawable folder
welcome
 
:)
are you on fb ?
 
were r u frm?
 
from Manchester
what about you ?
 

last day (14 days later) »