Skip to main content

Posts

Showing posts with the label asset

Read File Names From Assets To A ListView

Here in this blog we are explaing how to load files names from asset and load it in a listview. Here we have saved certain html files inside assets/datas/.. Copy and Download the code... MainActivity public class MainActivity extends Activity { ListView list; String path; ArrayList<String> data = new ArrayList<String>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); list = (ListView) findViewById(R.id.listView1); path = getResources().getString(R.string.directory); showlist(); } private void showlist() { String[] data1 = null; // *****got all resource in "am" from asset********* AssetManager am = getResources().getAssets(); try { // ***** got all one by one in arraylist "data1" ********* data1 = am.list(path); } catch (Exception e) { } for (String name : data1) { // ***** removing all .htm from extension*...

Using external font in ANDROID

TextView text =(TextView) findViewById(R.id.textview); Typeface face; face = Typeface.createFromAsset(getAssets(), "AMAZB.TTF"); text.setTypeface(face); text.setTextSize(30); text.setTextColor(Color.WHITE);