john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

textview colors INCOMPLETE

package kittyandbear.net;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.TextView;
import android.graphics.Color;

public class Notepadv1Activity extends Activity 
{
    @Override
    public void onCreate( Bundle savedInstanceState ) 
    {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.main );
        TextView tv = new TextView( this );     // http://developer.android.com/reference/android/widget/TextView.html
        setTextColors( tv );

    if( isExternalStorageWriteable() )
    {
        tv.setText( "I can write a file!" );
    }
    else
    {
        tv.setText( "I can not write a file =[" );
    }
        setContentView( tv );
    }

    private boolean isExternalStorageWriteable( )
    {
        boolean result = false;
        String state = Environment.getExternalStorageState();

        // http://developer.android.com/reference/android/os/Environment.html
        if( state.equals( Environment.MEDIA_MOUNTED )  &&  !state.equals( Environment.MEDIA_MOUNTED_READ_ONLY ) )
        {       result = true;
        }
        return result;
    }

    private void setTextColors( TextView tv )
    {
        int bgcolor = Color.parseColor( "#D3D3D3" );
        int fgcolor = Color.parseColor( "#000000" );      
        tv.setBackgroundColor( bgcolor );     
        tv.setTextColor( fgcolor );     
    }

} //end class

  • « BAT for loop readfile increment if statements
  • Wget podcasts »

Published

Jan 8, 2012

Category

android

~91 words

Tags

  • android 9
  • colors 1
  • incomplete 22
  • java 252
  • textview 1