次のようなレイアウト用の xml ファイルが 3 つあります。
- activity_behind_left_simple.xml
- activity_behind_right_simple.xml
- activity_main.xml
textViews を実装しactivity_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;
}