RapsFan1981
RapsFan1981

Reputation: 1197

Android EditText line numbers

I'm making a html IDE and want to add line numbers to an EditText. I tried a think TextView beside the EditText but it has its problems. Any ideas?

EDIT:

private List<String> items = null;
private EditText ideText;
private TextView ln;

     @Override
        public void onCreate(Bundle icicle) {
            super.onCreate(icicle);
            setContentView(R.layout.main);
            ideText = (EditText) findViewById(R.id.ide);
            ln = (TextView) findViewById(R.id.lineNumbers);
            // Create Line Numbers
           for(int i=0;i<ideText.getLineCount();i++){
               ln.append(i +"\n");
           }
        }

Upvotes: 0

Views: 1285

Answers (1)

Michał Z.
Michał Z.

Reputation: 4119

You should create a custom View that extends EditText.

Upvotes: 2

Related Questions