I have spinner with one Text View and one Image View and when click on one of its item I only want to show the text not the Image View , how can I get the image view plus I have a custom spinner layout , any help will be appreciated:
spinner_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Single Item Design -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/txt"
android:layout_width="60dp"
android:layout_height="40dp"
android:padding="10dp"
android:layout_gravity="center_vertical"
>
</TextView>
<ImageView
android:id="#+id/img"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="10dp"
android:layout_gravity="center_vertical"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="10dp" />
</LinearLayout>
MainActivity.java
public class MainActivity extends AppCompatActivity {
private Spinner spinner;
int count=0;
int pre_pos=-1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<ItemData> list = new ArrayList<>();
list.add(new ItemData("EUR", R.drawable.ger));
list.add(new ItemData("USD", R.drawable.usa));
list.add(new ItemData("JPY", R.drawable.jap));
list.add(new ItemData("GBP", R.drawable.gb));
list.add(new ItemData("AUD", R.drawable.aus));
list.add(new ItemData("CHF", R.drawable.swiss));
list.add(new ItemData("CAD", R.drawable.can));
list.add(new ItemData("SEK", R.drawable.sweden));
list.add(new ItemData("NZD", R.drawable.newz));
list.add(new ItemData("KRW", R.drawable.skorea));
//list.add(new ItemData("Usd",R.drawable.usd));
//list.add(new ItemData("Jpy",R.drawable.jpy));
//list.add(new ItemData("Aud",R.drawable.aud));
Spinner sp = (Spinner) findViewById(R.id.spinner);
SpinnerAdapter adapter = new SpinnerAdapter(this,
R.layout.spinner_layout, R.id.txt, list);
ArrayList<ItemData> list2= new ArrayList<>();
list2.add(new ItemData("EUR", R.drawable.imag1));
list2.add(new ItemData("USD", R.drawable.imag2));
list2.add(new ItemData("JPY", R.drawable.imag3));
//listener of spinner
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
// how could i hide the image view of selected item
}
#Override
public void onNothingSelected(AdapterView<?> parentView) {
// your code here
}
}
}
SpinnerAdapter.java
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
/**
* Created by Abbas on 12/11/2016.
*/
public class SpinnerAdapter extends ArrayAdapter<ItemData> {
static int count=0;
int groupid;
Activity context;
ArrayList<ItemData> list;
LayoutInflater inflater;
SharedPreferences sharedPreferences;
public SpinnerAdapter(Activity context, int groupid, int id, ArrayList<ItemData>
list){
super(context,id,list);
this.list=list;
inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.groupid=groupid;
}
public View getView(int position, View convertView, ViewGroup parent ){
View itemView=inflater.inflate(groupid,parent,false);
ImageView imageView=(ImageView)itemView.findViewById(R.id.img);
imageView.setImageResource(list.get(position).getImageId());
TextView textView=(TextView)itemView.findViewById(R.id.txt);
textView.setText(list.get(position).getText());
return itemView;
}
public View getDropDownView(int position, View convertView, ViewGroup
parent){
return getView(position,convertView,parent);
}
}
Related
Friends, I am a new developer in the field of android and I want to develop an application like that it will sort the Gridview by using a spinner, I had applied the XML array for Spinner and Custom adapter also I tried various solution but it didn't work so please help me
Moodel Class for adapter of GridAdapter
package braniacs.com.gridupdaterapp;
/**
* Created by grimReaper on 12/4/2017.
*/
public class GridModel {
String thingName;
public String getThingName() {
return thingName;
}
public void setThingName(String thingName) {
this.thingName = thingName;
}
}
MainActvityCode along adapter in it!
package braniacs.com.gridupdaterapp;
import android.content.Context;
import android.database.Cursor;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
GridView mGridViewA;
Spinner mspinnerColony;
ArrayList<GridModel> ColonyArray;
String[] ColonyArraySpinnerWali = {"hie", "wasteage", "short", "Lovely", "RUSSIA", "ASIA", "KOREA"};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGridViewA = findViewById(R.id.mgridViewApp);
mspinnerColony = findViewById(R.id.spnr_colony);
ColonyArray = new ArrayList<>();
ArrayAdapter mArrayAdapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, ColonyArraySpinnerWali);
mspinnerColony.setAdapter(mArrayAdapter);
mspinnerColony.setSelection(0);
mspinnerColony.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
if (i != 0) {
GridModel mgRIDmODEL = new GridModel();
TextView mTitle = (TextView) view;
mgRIDmODEL.setThingName(mTitle.getText().toString());
ColonyArray.add(mgRIDmODEL);
GridVuCustionAdapter adapter = new GridVuCustionAdapter(MainActivity.this,
R.layout.custom_gridvu_design, ColonyArray);
mGridViewA.setAdapter(adapter);
}
}
#Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
mGridViewA.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
// CLICK LISTENER AREA
}
});
}
public static class GridVuCustionAdapter extends ArrayAdapter<GridModel> {
LayoutInflater mLayoutInflater;
ArrayList<GridModel> objects;
Context context;
int resource;
public GridVuCustionAdapter(#NonNull Context context, int resource, #NonNull ArrayList<GridModel> objects) {
super(context, resource, objects);
mLayoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
this.objects = objects;
this.context = context;
this.resource = resource;
}
#Override
public int getCount() {
return objects.size();
}
#NonNull
#Override
public View getView(int position, #Nullable View convertView, #NonNull ViewGroup parent) {
convertView = mLayoutInflater.inflate(resource, parent, false);
TextView txtVuTitle = convertView.findViewById(R.id.txt_vu_name);
ImageView imgVuCancel = convertView.findViewById(R.id.img_vu_cancel);
txtVuTitle.setText(objects.get(position).getThingName());
return convertView;
}
}
}
the xml file for custom design for the design is simple here
<LinearLayout 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="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:id="#+id/txt_vu_name"
android:layout_weight="1.7"
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="TextView" />
<ImageView
android:layout_weight="0.2"
android:id="#+id/img_vu_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/btn_dialog" />
</LinearLayout>
the xml file is here for the activity
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="braniacs.com.gridupdaterapp.MainActivity">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mgridViewApp"
android:layout_width="0dp"
android:layout_height="200dp"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.498" />
<Spinner
android:id="#+id/spnr_colony"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="45dp" />
</android.support.constraint.ConstraintLayout>
I have created a listview called popuplistfragment.java and list_view.xml.I have added textview in xml file but I dont know where to add code to change the textview in the listview.
import android.app.ListFragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
public class PopupListFragment extends ListFragment implements OnItemClickListener {
TextView textview;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.list_item, container, false);
return view;
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.quotes, android.R.layout.simple_list_item_1);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}
#Override
public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
//Toast.makeText(getActivity(), "Item: " + position, Toast.LENGTH_SHORT).show();
String item = (String) parent.getItemAtPosition(position);
Log.v("check", "item is clicked");
Intent myIntent = new Intent(getActivity(), SwipeViews.class);
myIntent.putExtra("key", item);
myIntent.putExtra("index", position);
startActivity(myIntent);
}
}
And this is the list_view.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeight"
android:background="#drawable/back_listview">
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:longClickable="false"
>
</ListView>
<TextView
android:id="#+id/text1"
android:textColor="#e15258"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:maxLines="1"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
Firstly you need to extend Adapter class
public class ListAdapter extends ArrayAdapter<String> {
String [] mQuotes;
public ListAdapter(String [] quotes){
mQuotes = quotes;
}
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
v = layoutInflater.inflate(R.layout.itemlistrow, null);
}
TextView quoteTextView = v.findViewById(R.id.quote_textView);
quoteTextView.setText(mQuotes[position])
return v;
}
#Override
public int getCount() {
return quotes.length;
}
}
Then implement other methods.
The next step is to change next code
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
String [] QuoteArray = getResources().getStringArray(R.array.quotes);
ListAdapter adapter = new ListAdapter(QuoteArray);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}
Then add itemlistrow.xml to Layout folder and change it so:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/quote_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
You can customize itemlistrow.xml as you want
So I have a Listview full of rows, each with a textview and a spinner. I use an ArrayAdapter to fill in each row. There is a single layout for all the rows.
I want to have a button underneath all the rows that I can press so that it saves all the selections of the spinners in a Text file.
My problem though is I dont know how to reference the spinners anymore since I use the single layout approach. I no longer have unique IDs: (spinner1, spinner2, spinner3, etc.) for each one because they are filled in row by row.
Any advice on how to approach this problem so I can reference each spinner and call their "get text" method?
The more detail the better, thanks in advance!
This is how I would do it: If the model object type of your array doesn't have a variable for the current spinner selection, you need to update your model or extend your Adapter so that you can capture the current selection of the spinner for that item.
In your adapter's getView(), when you create the spinner, add an OnItemSelectedListener to it that updates the model for its corresponding item in the array.
Then when the save button is pressed, you simply loop through the items in the adapter's array and get all the current spinner values.
Here is a code example:
MainActivity.java
package com.example.spinnerdemo;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
public class MainActivity extends Activity {
private static final String TAG = "MainActivity";
private static final String[] mValues = {
"Strongly Agree",
"Agree",
"Neutral",
"Disagree",
"Strongly Disagree"
};
public static class MyModel {
public String text;
public int spinnerVal;
public MyModel(String txt, int val) {
text = txt; spinnerVal = val;
}
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final List<MyModel> items = createItemList();
ListView listView = (ListView) findViewById(R.id.listView1);
final MyListAdapter adapter = new MyListAdapter(this, items);
listView.setAdapter(adapter);
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// here is where we get all the spinner values
Log.d(TAG, "------- save button clicked");
for (MyModel model : items) {
Log.d(TAG, model.text + " : " + mValues[model.spinnerVal]);
}
Log.d(TAG, "-------");
}
});
}
public static class MyListAdapter extends ArrayAdapter<MyModel> {
public MyListAdapter(Context context, List<MyModel> objects) {
super(context, 0, objects);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_item, parent, false);
}
final MyModel model = (MyModel) getItem(position);
TextView textView = (TextView) convertView.findViewById(R.id.textView1);
textView.setText(model.text);
Spinner spinner = (Spinner) convertView.findViewById(R.id.spinner1);
spinner.setAdapter(new ArrayAdapter<String>(parent.getContext(),
android.R.layout.simple_spinner_dropdown_item,
android.R.id.text1, mValues));
// here is where the spinner gets the value from the model
spinner.setSelection(model.spinnerVal);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// here is where we update the model with the current position of the spinner
model.spinnerVal = position;
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
return convertView;
}
}
private List<MyModel> createItemList() {
List<MyModel> items = new ArrayList<MyModel>();
// initialize with "Neutral" spinner setting
items.add(new MyModel("question 1", 2));
items.add(new MyModel("question 2", 2));
items.add(new MyModel("question 3", 2));
items.add(new MyModel("question 4", 2));
items.add(new MyModel("question 5", 2));
return items;
}
}
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"
tools:context="com.example.spinnerdemo.MainActivity" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Save" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
</ListView>
</RelativeLayout>
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
I meet a problem developing an android project.
Using adapter, I place many items in a ListView, and there is an ImageButton in each item. Now I want to set a click listener for these ImageButtons. What should I do?
This achieves your desired result. Its functionality is the button itself has a click response different from the container, which also has a response.
MainActivity.java
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
ListView lv = (ListView) findViewById( R.id.list );
lv.setOnItemClickListener(
new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0,
android.view.View arg1, int arg2, long arg3) {
Toast.makeText( MainActivity.this,
"List item clicked",
Toast.LENGTH_SHORT).show();
}
});
ArrayList<String> items = new ArrayList<String>();
items.add( "item1");
items.add( "item2");
items.add( "item3");
ListAdapter adapter = new ListAdapter( this, items);
lv.setAdapter( adapter );
}
}
ListAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.BaseAdapter;
import android.widget.Toast;
import java.util.List;
public class ListAdapter extends BaseAdapter {
public ListAdapter(Context context,
List<String> items ) {
inflater = LayoutInflater.from( context );
this.context = context;
this.items = items;
}
public int getCount() {
return items.size();
}
public Object getItem(int position) {
return items.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
String item = items.get(position);
View v = null;
if( convertView != null )
v = convertView;
else
v = inflater.inflate( R.layout.item, parent, false);
TextView itemTV = (TextView)v.findViewById( R.id.item);
itemTV.setText( item );
ImageButton button =
(ImageButton)v.findViewById( R.id.button);
button.setOnClickListener(
new OnClickListener() {
public void onClick(View v) {
Toast.makeText( context,
"ImageButton clicked",
Toast.LENGTH_SHORT).show();
}
});
return v;
}
private Context context;
private List<String> items;
private LayoutInflater inflater;
}
item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants" >
<TextView
android:id="#+id/item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textSize="28sp" />
<ImageButton
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#android:color/transparent"
android:src="#drawable/emo_im_cool" />
</RelativeLayout>
list.xml
<?xml version="1.0" encoding="utf-8" ?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/list" />
Try it out and hopefully you can see what's going on to learn what you need
1.I want to change the textSize of the items in my listView.
I've a xml file with a button and a listView in a Fragment layout.
I can't change the size of the text's Items.
I tried, in xml, android:textSize and i've searched here but the question is not the same, because normally they haven't a button inside the activity (in my case, a fragment).
My onResume with ArrayAdapter
public void onResume()
{
super.onResume();
ListView listaDeEquipas=(ListView)getView().findViewById(R.id.listaEquipas);
final ArrayAdapter<Equipa> itemsAdapter = new ArrayAdapter<Equipa>(getActivity(), android.R.layout.simple_list_item_1, listaEquipas);
listaDeEquipas.setAdapter(itemsAdapter);
itemsAdapter.notifyDataSetChanged();
listaDeEquipas.setOnItemLongClickListener(new OnItemLongClickListener(){
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
listaEquipas.remove(position);
itemsAdapter.notifyDataSetChanged();
return false;
}
});
}
My xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/addEquipa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:padding="20dip"
android:textColor="#ffffffff"
android:background="#FFCC0000"
android:textStyle="bold"
android:textSize="40sp"
android:text="Inserir Equipa"
android:onClick="true"/>
<ListView
android:id="#+id/listaEquipas"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_gravity="center"
android:fastScrollEnabled="true">
</ListView>
</LinearLayout>
In your ListView adapter, place this line in your getView():
TextView text = (TextView) v.findViewById(android.R.id.text1);
text.setTextSize(30);
You might need to implement a custom adapter for the ListView, like this:
package de.vogella.android.listactivity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class myArrayAdapter extends ArrayAdapter<Equipa> {
private final Context context;
private final Equipa[] values;
public myArrayAdapter(Context context,Equipa[] values) {
super(context, android.R.layout.simple_list_item_1, values);
this.context = context;
this.values = values;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
TextView text = (TextView) rowView.findViewById(android.R.id.text1);
text.setTextSize(30);
textView.setText(values[position]); // Set what you want the text to be here
return rowView;
}
}