Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Eclipse Log.e println needs a message


AD MOB

Log.e println needs a message error.
E/AndroidRuntime(330): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{b.paint/b.paint.MainActivity}: java.lang.NullPointerException: println needs a message

Try this code:

		// Error
                String s = null;
		Log.e("bla", s); // !!! error Log.e println needs a message error.
                // OK
		String s = null;
		Log.e("bla", s+""); // OK 



397LW NO topic_id




AD

Další témata ....(Topics)


359

Not visible layout changes on testing device | not-visible-layout-changes-on-testing-device


Delete - unistal app from testing device - emulator and try again RUN - DEBUGG your app.
56

Change background color dynamically View TableRow setBackgroundColor Android example | change-background-color-dynamically-view-tablerow-android-example


How change background color of View Android sample.

MainActivity.java

public class MainActivity extends Activity {
TextView hTextView;
TableRow hTableRow;
Button hButton, hButtonStop;
private Handler mHandler = new Handler();
private int nCounter = 0;
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        hTextView = (TextView)findViewById(R.id.idTextView);
        hButton = (Button)findViewById(R.id.idButton);
        hButton.setOnClickListener(mButtonStartListener);
        hTableRow = (TableRow)findViewById(R.id.idTableRow1);


        
        
    } // end onCreate

 View.OnClickListener mButtonStartListener = new OnClickListener() {
	public void onClick(View v) {
           hTableRow.setBackgroundColor(Color.YELLOW);
	}
 };
}





main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >


<TableLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/tableLayout1">
    <TableRow android:id="@+id/idTableRow1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:background="#5655AA">
<TextView  
	android:id="@+id/idTextView"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
    
    </TableRow>
</TableLayout>
</LinearLayout>
338

Linkify TextView clickable phone number url adress | linkify-textview-clickable-phone-number-url-adress


android:autoLink="all"

 <!-- text1 automatically linkifies things like URLs and phone numbers. -->
  <TextView
            android:id="@+id/text1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:autoLink="all"
            android:text="@string/link_text_auto"
            />
61

Get text file content from raw folder to StringBuilder Android example | get-text-file-content-from-raw-folder-to-stringbuilder-android-example


StringBuilder, res/raw folder, try catch finaly throws, BufferedReader, InputStream, openRawResource, getResources Android example

MainActivity.java


public class MainActivity extends Activity {
TextView txtV;
	Context cntx;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        txtV = (TextView)findViewById(R.id.idLabel);
        cntx = this;
        try {
			StringBuilder strBuilder = myFunction(cntx);
			txtV.setText(strBuilder);
		} catch (IOException e) {
			e.printStackTrace();
		}

        
    }
    
    
    private StringBuilder myFunction(Context context) throws IOException {
        final Resources resources =  context.getResources();
        InputStream inputStream = resources.openRawResource(R.raw.my_file);
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder strBuild = new StringBuilder();
        try {
            String line;
            while ((line = reader.readLine()) != null) {
            	strBuild.append(line);
            }
        } finally {
            reader.close();
        }
       return strBuild; 
       
    }
}

190

Get Screen Size Pixels per Inch Android example | get-screen-pixels-android-example


The exact physical pixels per inch of the screen
Get size of pixel
Get DPI
Get count of pixels per inch

        float mXDpi;
        float mYDpi;
           DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            mXDpi = metrics.xdpi; // The exact physical pixels per inch of the screen in the X dimension. 
            mYDpi = metrics.ydpi;
          float  mMetersToPixelsX = mXDpi / 0.0254f; // 1 inch == 0.0254 metre
          float  mMetersToPixelsY = mYDpi / 0.0254f;




Editace: 2014-02-15 20:27:55
Počet článků v kategorii: 397
Url:eclipse-log-e-println-needs-a-message

AD
11 Share
Share
Tweet