Here is my XML:
<RelativeLayout 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:background="#E0E0E0"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.ccb.lldm.lldmhimnario.Cantos">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:elevation="25dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#303F9F"
app:popupTheme="@style/AppTheme.PopupOverlay">
<TextView
android:layout_width="wrap_content"
android:textColor="#E0E0E0"
android:text="Cantos"
android:id="@+id/toolbarCantos"
android:textSize="25sp"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ListView"
android:layout_below="@+id/toolbar"
android:layout_alignParentBottom="true">
</ListView>
</RelativeLayout>
This is for my listview.
Here is my custom listview xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:background="#E0E0E0"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:text="Canto: "
android:background="@drawable/text_ripple"
android:textColor="#303F9F"
android:id="@+id/textCanto"
android:textSize="25sp"
android:layout_height="45dp" />
</LinearLayout>
Here is my java files:
public class Cantos extends AppCompatActivity {
ListView lv;
Context context;
ArrayList cantoList;
public static String[] cantos = {"1: Abre Tu Oido", "2: A Cristo Quiero", "3: Acerquese Mi Clamor", "4: A Cristo Yo Alabare",
"5: Acude Dios", "6: Adelante", "7: A Dios Canto", "8: Adios Para Siempre", "9: Ahora Senor", "10: A Jesucristo Ven",
"11: Alabad A Dios"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cantos);
initTypeface();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
context = this;
lv = (ListView)findViewById(R.id.ListView);
lv.setAdapter(new CustomAdapter(this, cantos));
}
private void initTypeface() {
Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/AftaSerifThin-Regular.otf");
TextView text = (TextView) findViewById(R.id.toolbarCantos);
text.setTypeface(myTypeface);
}
}
And here is my last Java File:
public class CustomAdapter extends BaseAdapter {
String[] result;
Context context;
private static LayoutInflater inflater = null;
public CustomAdapter(Cantos cantos, String[] cantos1) {
result = cantos1;
context = cantos;
inflater = (LayoutInflater)context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return result.length;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
public class Holder
{
TextView tv;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder = new Holder();
View rowView;
rowView = inflater.inflate(R.layout.cantos_list, null);
holder.tv = (TextView) rowView.findViewById(R.id.textCanto);
holder.tv.setText(result[position]);
return rowView;
}
}
I'm new to android and I'm getting a hang of it, but I need help in things like this. Thanks in advance!