Listview not updating from fragment - android

When the user clicks a button, a new string is added to the list view, but nothing is appearing when i click it. How exactly would I do that?
MatchesList.java
The class that adds the strings to the list view
import java.util.ArrayList;
import com.actionbarsherlock.app.SherlockListActivity;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
public class MatchesList extends SherlockListActivity{
ArrayList<String> listItems = new ArrayList<String>();
ArrayAdapter<String> adapter;
int matchNum=0;
Button addMatch;
#Override
public void onCreate(Bundle icicle){
super.onCreate(icicle);
setContentView(R.layout.fragment_matches);
adapter= new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
listItems);
setListAdapter(adapter);
addMatch = (Button) findViewById(R.id.addMatchBtn);
addMatch.setOnClickListener(new OnClickListener(){
public void onClick(View v){
addMatch(v);
}
});
}
public void addMatch(View view){
matchNum += 1;
listItems.add("Match " + matchNum);
adapter.notifyDataSetChanged();
}
}
MatchesFragment.java
import com.actionbarsherlock.app.SherlockFragment;
import android.os.Bundle;
import android.view.*;
public class MatchesFragment extends SherlockFragment{
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
return inflater.inflate(R.layout.fragment_matches, container, false);
}
}
fragment_matches.xml
<LinearLayout 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"
tools:context=".MatchesFragment" >
<Button
android:id="#+id/addMatchBtn"
android:layout_width="50dp"
android:layout_height="40dp"
android:text="Add a Match"
/>
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="fill_parent"></ListView>
</LinearLayout>

listAdapter.add(...) instead (and no need to call notifyDataSetChanged() then).
ArrayAdapter can use another list internally if you are using filter for example, besides not good practice as the ArrayAdapter could just do a defensive copy of that list passed in the constructor (it doesn't though). It is using an internal lock to protect that list though. So really isn't supposed to modify it outside.

Related

I have a problem with intent it does not work

I need a help with my app, I am creating music app by using listView and adapter,image for main activity
i use imagebutton to go to details activity but when i click on it no thing happen
this is main activity code
package com.example.musicano;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<Song> songs=new ArrayList<Song>();
songs.add(new Song("See You Again","Wiz Knalifa"));
songs.add(new Song("Sorry","Justin Bieber"));
songs.add(new Song("Uptown Funk","Mark Ronson "));
songs.add(new Song("Blank Space","Taylor Swift"));
songs.add(new Song("Shake It Off","Taylor Swift"));
songs.add(new Song("Lean On","Major Lazer"));
songs.add(new Song("Hello","Adele"));
songs.add(new Song("Roa","Kary Perry"));
songs.add(new Song("Sugar","Sugar"));
songs.add(new Song("All About That Bass","Meghan Trainor"));
songs.add(new Song("Dark Horse","Katy Perry"));
songs.add(new Song("Counting Stars","Onerepublic"));
songs.add(new Song("Baby","Justin Biebe"));
songs.add(new Song("Chandelier","Meghan Sia"));
ListView listView=(ListView) findViewById(R.id.list);
SongAdapter adapter=new SongAdapter(this,songs);
listView.setAdapter(adapter);
LayoutInflater inflater = getLayoutInflater();
View view= inflater.inflate(R.layout.list_item,listView,false);
ImageButton playMusic = (ImageButton)view.findViewById(R.id.playButton);
playMusic.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,Details.class);
startActivity(intent);
}
});
}
}
and custom adapter code is
package com.example.musicano;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
public class SongAdapter extends ArrayAdapter<Song> {
public SongAdapter (Activity context, ArrayList<Song>songs){
super(context,0,songs);
}
#Override
public View getView(int position, View convertView, ViewGroup parent){
Song cureentSong=getItem(position);
View listItemView=convertView;
if(listItemView==null){
listItemView= LayoutInflater.from(getContext()).inflate(R.layout.list_item,parent,false);
}
TextView songName=(TextView) listItemView.findViewById(R.id.text_view_song_name);
TextView artistName=(TextView) listItemView.findViewById(R.id.text_view_artist_name);
ImageButton playMusic=(ImageButton) listItemView.findViewById(R.id.playButton);
songName.setText(cureentSong.getSongName());
artistName.setText(cureentSong.getArtistName());
return listItemView;
}
}
and activity_main.xml contain
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/list"
tools:context=".MainActivity">
</ListView>
and list_item layout contain
<?xml version="1.0" encoding="utf-8"?>
<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:background="#FFFFFF"
android:id="#+id/relativlayout"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/text_view_song_name"
tools:text="one"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#232F34"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/text_view_artist_name"
tools:text="two"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="#232F34"/>
</LinearLayout>
<ImageButton
android:id="#+id/playButton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/play"
android:layout_marginRight="26dp"
android:layout_marginTop="26dp"
/>
</RelativeLayout>
that is it
What is reason for doing view.findViewById, the button is in MainActivity itself right?
Try the following and check if this works?
Hope this helps
ImageButton playMusic = (ImageButton)findViewById(R.id.playButton);
playMusic.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,Details.class);
startActivity(intent);
}
});
If the image button is in list_item_layout then add the click listener in the adapter instead of MainActivity. Then it should work.
Add the following in your adapter code:
ImageButton playMusic=(ImageButton) listItemView.findViewById(R.id.playButton);
playMusic.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(mContext,Details.class);
intent .addFlags(FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
}
});
Use the context used in your Adapters constructor create a instance
private Context mContext;
and inside your adapter's constructor assign it to context as shown below:
this.mContext = context
Hope this helps.

The activity is showing blank when it is opened from the Fragment Class

I have a fragment activity which is a listview. When the user clicks the an item from the listview it opens another activity. The new activity is loaded but shows as blank.
I have tried to recreate the activity but it does not solve the problem. I am comparatively new to Android and Java Coding. The app works fine. I can use the back button to go back to the list and click another item. The result is the same.
I tried everything possible but unable to fix it. Can some one help me on this?
Fragment Activity
package com.ornisoft.bloodbankapp;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.ornisoft.bloodbankapp.DataAdapter.MessageDataAdapter;
import com.ornisoft.bloodbankapp.DataModel.MessageDataModel;
import java.util.ArrayList;
public class MessageFragment extends Fragment {
DatabaseHelper db;
ArrayList<MessageDataModel> MessageDataModelArrayList;
MessageDataAdapter MessageDataAdapter;
Context context;
ListView lvMessages;
public MessageFragment(){}
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.listview_message, container, false);
context = container.getContext();
lvMessages = view.findViewById(R.id.lvMessages);
lvMessages.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent intent = new Intent(getActivity(), MessageActivity.class);
//intent.putExtra("id",l);
startActivity(intent);
}
});
db = new DatabaseHelper(context);
loadMessages();
return view;
}
public void loadMessages(){
MessageDataModelArrayList = db.getMessages();
MessageDataAdapter = new MessageDataAdapter(context,MessageDataModelArrayList);
lvMessages.setAdapter(MessageDataAdapter);
MessageDataAdapter.notifyDataSetChanged();
}
}
Message Activity
package com.ornisoft.bloodbankapp;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class MessageActivity extends AppCompatActivity {
DatabaseHelper db;
int messageID;
#Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.activity_message);
db = new DatabaseHelper(this);
Toast.makeText(MessageActivity.this, "Hello world " , Toast.LENGTH_SHORT).show();
/*messageID= Integer.parseInt(getIntent().getStringExtra("id"));
MessageModel messageModel = db.getMessage(messageID);*/
}
}
Layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MessageActivity">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Thank you
I found the error. I am using the wrong create class on the MessageActivity.
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState)
when I changed it to
protected void onCreate(Bundle savedInstanceState)
the problem is solved and it works perfect.
Thank you all.

How to delete a particular view on the click of button in a ListView in Android?

I have made a custom view that consists of two text views and one button. I just want when i click on the button then the respective view is gone and list adjust itselt.
here is my MainActivity.java
package com.dv.deletev;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.ListView;
public class MainActivity extends Activity {
ListView lv;
String name[]={"Ankit","Arora","Arun","yadav"};
String no[]={"AnAnaAN","cccc","bbbbb","aaa"};
static CustomAdapter obj;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv=(ListView)findViewById(R.id.listView1);
obj=new CustomAdapter(MainActivity.this,name,no);
lv.setAdapter(obj);
//obj.notifyDataSetChanged();
}
public static CustomAdapter take()
{
return obj;
}
}
CustomAdapter.java
package com.dv.deletev;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
import com.dv.deletev.*;
public class CustomAdapter extends ArrayAdapter<String>
{
String name[];
String no[];
Context con;
MainActivity a;
public CustomAdapter(Context con,String a[],String b[])
{
super(con,R.layout.second,a);
name=a;
this.con=con;
no=b;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater lv=(LayoutInflater) con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView=lv.inflate(R.layout.second, null);
TextView tv1=(TextView)convertView.findViewById(R.id.textView1);
TextView tv2=(TextView)convertView.findViewById(R.id.textView2);
Button bt=(Button)convertView.findViewById(R.id.button1);
final List<String> arr1;
final List<String> arr2;
arr1=(List<String>) Arrays.asList(name);
arr2=(List<String>) Arrays.asList(no);
final ArrayList<String> arr=new ArrayList<String>(arr1);
final ArrayList<String> ar=new ArrayList<String>(arr2);
bt.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
arr.remove(position);
ar.remove(position);
a.take().notifyDataSetChanged();
//CustomAdapter.this.notifyDataSetChanged();}
}
});
tv1.setText(name[position]);
tv2.setText(no[position]);
return convertView;
}
}
Second.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Button" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:layout_marginLeft="30dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_alignParentTop="true"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
activity_main.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.dv.deletev.MainActivity" >
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</RelativeLayout>
there is no such problem on logic part everything works fine, ListView appeared is what i wanted but on the click of button nothing happens.
Any suggestions...?
There are a lot of problems in this code, sorry if i will seem salty, i fixed only some necessary things:
two arrays of string with same length passed in an adapter. It's better to use a custom object that wraps these two string instead of two arrays
the transformation to arraylist without any purpose
the reference to the adapter from activity context instead from the adapter itself
the confusion about use arrays items but remove lists items
the code indentation
the code variable's name
package com.dv.deletev;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
import com.dv.deletev.*;
public class CustomAdapter extends ArrayAdapter<String>
{
String name[];
String no[];
Context con;
MainActivity a;
//declare them global
ArrayList<String> arr;
ArrayList<String> ar;
public CustomAdapter(Context con,String a[],String b[])
{
super(con,R.layout.second,a);
name=a;
this.con=con;
no=b;
// initialize them in constructor
arr = new ArrayList<String>(Arrays.asList(name));
ar = new ArrayList<String>(Arrays.asList(no);
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater lv=(LayoutInflater) con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView=lv.inflate(R.layout.second, null);
TextView tv1=(TextView)convertView.findViewById(R.id.textView1);
TextView tv2=(TextView)convertView.findViewById(R.id.textView2);
Button bt=(Button)convertView.findViewById(R.id.button1);
bt.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
arr.remove(position);
ar.remove(position);
notifyDataSetChanged();
//don't use reference of the adapter itself from the activity
//a.take().notifyDataSetChanged();
//CustomAdapter.this.notifyDataSetChanged();}
}
});
// set them to list
tv1.setText(arr.get(position));
tv2.setText(ar.get(positon));
return convertView;
}
}
You convert the array to a list and remove the list item but you don't convert the list back to the array, so the remove is lost.
ArrayAdapter already has a remove() method, you should just use that.

How to link listView to another class when list item is selected?

Hi I am trying to make an app that shows a list of items using listView and when the user select one of the items from the list. the app will call the specific class that is link to the item selected however i encountered an error at the second #override, saying that the override must override a super class. Here are my codes for class and xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/botanicgate" />
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
package com.fyp.gulliver;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class HotSpot extends ListActivity{
/** Called when the activity is first created. */
String places[] = {"BotanicGarden", "Sentosa"};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hotspot);
ListView listView = (ListView) findViewById(R.id.listView);
listView.setAdapter(new ArrayAdapter
(HotSpot.this, android.R.layout.simple_list_item_1,
places));
listView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
Class ourClass;
String item = ((TextView)view).getText().toString();
try {
ourClass = Class.forName
("com.fyp.gulliver." + item);
Intent ourIntent = new Intent(HotSpot.this, ourClass);
startActivity(ourIntent);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
}
As i am still new to android, thus i do not know what mistakes i have made, I will be grateful if another one can help me to solve my error thank you :D
Try changing this:
listView.setOnItemClickListener(new OnItemClickListener();
to
listView.setOnItemClickListener(new AdapterView.OnItemClickListener();
and remove the 2nd #Override

How do we create select (combo) box in android

I want integrate one combo filled with currency types. please tell me any way to create select box in android. i have created spinner but i have similar different views to show on page. and it is not looking attractive. please share any code for select.
use this dynamic_spinner_main.java
package example.sampleLocalization;
import java.util.ArrayList;
//import com.matthias.dynamicSpinnerT.R;
//import com.matthias.dynamicSpinnerT.R.id;
//import com.matthias.dynamicSpinnerT.R.layout;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
public class dynamic_spinner_main extends Activity {
private Spinner m_myDynamicSpinner;
private EditText m_addItemText;
private ArrayAdapter<CharSequence> m_adapterForSpinner;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_spinner);
///////////////////////////////////////////////////////////////
//grab our UI elements so we can manipulate them (in the case of the Spinner)
// or add listeners to them (in the case of the buttons)
m_myDynamicSpinner = (Spinner)findViewById(R.id.dynamicSpinner);
m_addItemText = (EditText)findViewById(R.id.newSpinnerItemText);
Button addButton = (Button)findViewById(R.id.AddBtn);
Button clearButton = (Button)findViewById(R.id.ClearBtn);
////////////////////////////////////////////////////////////////
//create an arrayAdapter an assign it to the spinner
m_adapterForSpinner = new ArrayAdapter(this, android.R.layout.simple_spinner_item);
m_adapterForSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
m_myDynamicSpinner.setAdapter(m_adapterForSpinner);
m_adapterForSpinner.add("gr");
////////////////////////////////////////////////////////////////
//add listener for addButton
addButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
addNewSpinnerItem();
}
});
////////////////////////////////////////////////////////////////
//add listener for addButton
clearButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
clearSpinnerItems();
}
});
}
private void addNewSpinnerItem() {
CharSequence textHolder = "" + m_addItemText.getText();
m_adapterForSpinner.add(textHolder);
}
private void clearSpinnerItems() {
m_adapterForSpinner.clear();
m_adapterForSpinner.add("dummy item");
}
}
main_spinner.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText android:layout_height="wrap_content"
android:layout_margin="4px"
android:id="#+id/newSpinnerItemText"
android:layout_width="fill_parent"></EditText>
<Button android:layout_height="wrap_content"
android:id="#+id/AddBtn"
android:layout_margin="4px"
android:layout_width="fill_parent"
android:text="Add To Spinner"></Button>
<Button android:layout_height="wrap_content"
android:id="#+id/ClearBtn"
android:layout_margin="4px"
android:layout_width="fill_parent"
android:text="Clear Spinner Items"></Button>
<Spinner android:layout_height="wrap_content"
android:id="#+id/dynamicSpinner"
android:layout_margin="4px"
android:layout_width="fill_parent"></Spinner>
</LinearLayout>

Categories

Resources