0
final TextView appTextView = new TextView(getContext());    
appTextView.setTextSize(12);
appTextView.setGravity(Gravity.CENTER_HORIZONTAL);
appTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
appTextView.setMaxLines(2);
appTextView.setPadding(10, 0, 10, 0);
appTextView.setText("Some text");

addView(appTextView);

E/AndroidRuntime( 2448): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 2448):    at android.widget.TextView.makeNewLayout(TextView.java:5130)
E/AndroidRuntime( 2448):    at android.widget.TextView.onMeasure(TextView.java:5317)
E/AndroidRuntime( 2448):    at android.view.View.measure(View.java:8313)
E/AndroidRuntime( 2448):    at com.venturezlab.tvlauncher.views.AppsLayout.refreshApps(AppsLayout.java:51)
E/AndroidRuntime( 2448):    at com.venturezlab.tvlauncher.views.AppsLayout.<init>(AppsLayout.java:30)
E/AndroidRuntime( 2448):    ... 25 more

为什么?没有椭圆,这很好用。

4

0 回答 0