A blog for technology, SEO tips, website development and open source programming.

Display ASCII character on Android ListView

0 586


The post shows a simple example displaying ASCII code and character on ListView.

package com.panayiotisgeorgiou.androidlistviewascii;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ActionBarActivity {

ListView listAscii;
AsciiCode Asciis[];
ArrayAdapter asciiArrayAdapter;

protected void onCreate(Bundle savedInstanceState) {
listAscii = (ListView) findViewById(R.id.asciilist);

asciiArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1, android.R.id.text1, Asciis);

private void initAsciis() {
Asciis = new AsciiCode[128];
for (int i = 0; i < 128; i++) {
Asciis[i] = new AsciiCode(i);

class AsciiCode{
int id;
char charAscii;

AsciiCode(int id){
this.id = id;
charAscii = (char)id;

public String toString(){
String.format(“%03d”, id)
+ ” /(hex) 0x” + String.format(“%02x”, id).toUpperCase()
+ ” : ” + charAscii;




Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More