Multiple lines to get in Android like in Notepad -


i new android, developing application, in app, want multiple lines enter data in notepad. need lines fit phone screen. what's wrong in code?

also, code entering xml file? not mentioned xml file name in java file. code not showing error, not running.

this linededittext.java

package com.example.shiva.secretbook; import android.content.context; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.graphics.rect; import android.util.attributeset; import android.widget.edittext;  public class linededittext extends edittext { private rect mrect; private paint mpaint;  // need constructor layoutinflater public linededittext(context context, attributeset attrs) {     super(context, attrs);      mrect = new rect();     mpaint = new paint();     mpaint.setstyle(paint.style.fill_and_stroke);     mpaint.setcolor(color.parsecolor("#c0c0c0")); //set own color here }  @override protected void ondraw(canvas canvas) {     //int count = getlinecount();      int height = getheight();     int line_height = getlineheight();      int count = height / line_height;      if (getlinecount() > count)         count = getlinecount();//for long text scrolling      rect r = mrect;     paint paint = mpaint;     int baseline = getlinebounds(0, r);//first line      (int = 0; < count; i++) {          canvas.drawline(r.left, baseline + 1, r.right, baseline + 1, paint);         baseline += getlineheight();//next line     }      super.ondraw(canvas); }} 

this lined_edit_text.xml

     <?xml version="1.0" encoding="utf-8"?>      <relativelayout       xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="match_parent"      android:layout_height="match_parent"      android:paddingbottom="@dimen/activity_vertical_margin"      android:paddingleft="@dimen/activity_horizontal_margin"      android:paddingright="@dimen/activity_horizontal_margin"      android:paddingtop="@dimen/activity_vertical_margin">     <com.example.shiva.secretbook.linededittext     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@null"     android:inputtype="textmultiline|textnosuggestions"     android:minlines="10"     android:singleline="false"     android:imeoptions="actionnone"     android:text="start writing : " />    </relativelayout> 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -