我有三个用于布局的 xml 文件,例如
- activity_behind_left_simple.xml
- activity_behind_right_simple.xml
- activity_main.xml
我实现了 textViewsactivity_behind_left_simple.xml
并显示了菜单列表。它工作正常。
所以我也做了同样的activity_behind_right_simple.xml
事情。
但是,现在应用程序在启动后立即关闭:(
这是为什么?右侧有什么问题? activity_behind_left_simple.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/leftBehindMenuScroll" >
<LinearLayout style="@style/behindMenuScrollContent"
android:paddingTop="25dp" >
<TextView
style="@style/behindMenuItemTitle"
android:text="People" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<jp.fureco.IconView
android:id="@+id/iconViewItem4"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textSize="20dp"/>
<TextView
android:layout_marginLeft="10dp"
style="@style/behindMenuItemLabel"
android:text="Visitor" />
</LinearLayout>
</LinearLayout>
</ScrollView>
activity_behind_right_simple.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/rightBehindMenuScroll" >
<LinearLayout style="@style/behindMenuScrollContent"
android:paddingTop="25dp" >
<TextView
style="@style/behindMenuItemTitle"
android:text="Messages" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<jp.fureco.IconView
android:id="@+id/iconViewItem5"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textSize="20dp"/>
<TextView
android:layout_marginLeft="10dp"
style="@style/behindMenuItemLabel"
android:text="Received" />
</LinearLayout>
</LinearLayout>
</ScrollView>
SimpleSideDrawer.java
....
public View setLeftBehindContentView(int leftBehindLayout) {
final View content = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(leftBehindLayout, mLeftBehindBase);
String[] icons = getResources().getStringArray(R.array.icons);
IconView iv4 = (IconView) findViewById(R.id.iconViewItem4);
iv4.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "icons.ttf"));
iv4.setText(icons[8]);
IconView iv5 = (IconView) findViewById(R.id.iconViewItem5);
iv5.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "icons.ttf"));
iv5.setText(icons[315]);
mLeftPaddingRect = new Rect(content.getPaddingLeft(), content.getPaddingTop(), content.getPaddingRight(), content.getPaddingBottom());
mLeftBehindView = content;
return content;
}
....
然后,如果我删除这部分,应用程序将不再关闭。
我该如何解决?
IconView iv5 = (IconView) findViewById(R.id.iconViewItem5);
iv5.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "icons.ttf"));
iv5.setText(icons[315]);
MainActivity.java
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSize();
mActionBar = getActionBar();
mActionBar.hide();
mNav = new SimpleSideDrawer(this);
mNav.setLeftBehindContentView(R.layout.activity_behind_left_simple);
mNav.setRightBehindContentView(R.layout.activity_behind_right_simple);
....
SimpleSideDrawer.java我找到了这个。这有关系吗?
public View setRightBehindContentView(int rightBehindLayout) {
final View content = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(rightBehindLayout, mRightBehindBase);
mRightPaddingRect = new Rect(content.getPaddingLeft(), content.getPaddingTop(), content.getPaddingRight(), content.getPaddingBottom());
mRightBehindView = content;
return content;
}
第2部分
public View setLeftBehindContentView(int leftBehindLayout) {
final View content = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(leftBehindLayout, mLeftBehindBase);
String[] icons = getResources().getStringArray(R.array.icons);
IconView iv4 = (IconView) findViewById(R.id.iconViewItem4);
iv4.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "icons.ttf"));
iv4.setText(icons[25]);
IconView iv5 = (IconView) findViewById(R.id.iconViewItem5);
iv5.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "icons.ttf"));
iv5.setText(icons[26]);
IconView iv6 = (IconView) findViewById(R.id.iconViewItem6);
iv6.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "icons.ttf"));
iv6.setText(icons[117]);
mLeftPaddingRect = new Rect(content.getPaddingLeft(), content.getPaddingTop(), content.getPaddingRight(), content.getPaddingBottom());
mLeftBehindView = content;
return content;
}