-
-
Save mcapu/5860829 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<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" | |
android:orientation="vertical" | |
android:background="#e5e5e5"> | |
<ListView | |
android:id="@+id/cardListView" | |
android:layout_marginLeft="16dp" | |
android:layout_marginRight="16dp" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:divider="@null" | |
android:dividerHeight="0dp"> | |
</ListView> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item> | |
<shape android:shape="rectangle" | |
android:dither="true"> | |
<corners android:radius="2dp"/> | |
<solid android:color="#ccc" /> | |
</shape> | |
</item> | |
<item android:bottom="2dp"> | |
<shape android:shape="rectangle" | |
android:dither="true"> | |
<corners android:radius="2dp" /> | |
<solid android:color="@android:color/white" /> | |
<padding android:bottom="8dp" | |
android:left="8dp" | |
android:right="8dp" | |
android:top="8dp" /> | |
</shape> | |
</item> | |
</layer-list> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="?android:attr/listPreferredItemHeight"> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_marginLeft="6dp" | |
android:layout_marginRight="6dp" | |
android:layout_marginTop="4dp" | |
android:layout_marginBottom="4dp" | |
android:background="@drawable/background_card"> | |
<TextView | |
android:layout_gravity="left|center_vertical" | |
android:layout_width="fill_parent" | |
android:layout_weight="1" | |
android:textColor="@android:color/primary_text_light" | |
android:layout_height="wrap_content" /> | |
</LinearLayout> | |
</FrameLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
import android.content.Context; | |
import android.graphics.Typeface; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.TextView; | |
import com.packagename.util; | |
public class NowArrayAdapter extends ArrayAdapter<String> { | |
private ArrayList<String> values; | |
private Typeface fontface; | |
private LayoutInflater inflater; | |
public class CustomListItem { | |
TextView descText; | |
} | |
public NowArrayAdapter(Context context, int resource, ArrayList<String> commandsList) { | |
// TODO Auto-generated constructor stub | |
super(context, R.layout.list_item, commandsList); | |
values = new ArrayList<String>(); | |
values.addAll(commandsList); | |
Context appContext = context.getApplicationContext(); | |
fontFace = util.getTypeface(appContext, "fonts/Roboto-Light.ttf"); | |
inflater = LayoutInflater.from(appContext); | |
} | |
public View getView(int position, View convertView, ViewGroup parent) { | |
CustomListItem myListItem; | |
String myText = getItem(position); | |
if(convertView == null) { | |
convertView = inflater.inflate(R.layout.list_item, parent, false); | |
myListItem = new CustomListItem(); | |
myListItem.descText = (TextView) convertView.findViewById(R.id.commandText); | |
myListItem.descText.setTypeface(fontface); | |
convertView.setTag(myListItem); | |
} else { | |
myListItem = (CustomListItem) convertView.getTag(); | |
} | |
myListItem.descText.setText(myText); | |
//myListItem.descText.setTextSize(14); | |
return convertView; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.packagename.util; | |
import android.content.Context; | |
import android.graphics.Typeface; | |
import java.util.Hashtable; | |
public class util { | |
private static Hashtable<String, Typeface> fontCache = new Hashtable<String, Typeface>(); | |
public static Typeface getTypeface(Context context, String font) { | |
Typeface typeface = fontCache.get(font); | |
if (typeface == null) { | |
typeface = Typeface.createFromAsset(context.getAssets(), font); | |
fontCache.put(font, typeface); | |
} | |
return typeface; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. When I was trying to use the project, I had problems que the fonFace and the R.id.commandText, why ?