Display Ascii Grapheme On Listview

Posted on

It’s a elementary instance to display ASCII code together with grapheme on ListView.

package com.example.androidlistascii;  import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView;  populace flat MainActivity extends ActionBarActivity {   ListView listAscii;  AsciiCode Asciis[];  ArrayAdapter<AsciiCode> asciiArrayAdapter;   @Override  protected void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.activity_main);   listAscii = (ListView) findViewById(R.id.asciilist);   initAsciis();    asciiArrayAdapter = novel ArrayAdapter<AsciiCode>(this,     android.R.layout.simple_list_item_1, android.R.id.text1, Asciis);   listAscii.setAdapter(asciiArrayAdapter);  }   someone void initAsciis() {   Asciis = novel AsciiCode[128];   for (int i = 0; i < 128; i++) {    Asciis[i] = novel AsciiCode(i);   }  }    flat AsciiCode{   int id;   char charAscii;      AsciiCode(int id){    this.id = id;    charAscii = (char)id;   }      populace String toString(){    provide      String.format("%03d", id)     + " /(hex) 0x" + String.format("%02x", id).toUpperCase()     + " : " + charAscii;   }  } } 

<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: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.example.androidlistascii.MainActivity" >      <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text="https://rootandroid.org//"         android:textStyle="bold" />      <ListView         android:id="@+id/asciilist"         android:layout_width="wrap_content"         android:layout_height="wrap_content" />  </LinearLayout>