昨天我遇到了一个问题 - findViewById()为我的工具栏返回NULL.我通过内部人员四处寻找,但似乎我无法找到解决我的"大"问题的方法:D
这是styles.xml
<resources>
<style name = "AppTheme" parent = "@style/Theme.AppCompat.NoActionBar">
<!-- TODO: Create AppTheme -->
<item name="android:windowActionBar">false</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
这是activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:tools = "http://schemas.android.com/tools"
android:id = "@+id/drawer_layout"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
tools:context = ".Main" >
<LinearLayout
android:orientation="vertical"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent" >
<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar"
android:layout_width = "fill_parent"
android:layout_height = "@dimen/toolbar_height"
android:background = "@mipmap/bg_toolbar" >
<ImageView
android:id = "@+id/toolbar_drawer_button"
android:clickable="true"
android:layout_width = "wrap_content"
android:layout_height = "@dimen/toolbar_height"
android:src = "@mipmap/ic_drawer" …Run Code Online (Sandbox Code Playgroud) 我有一个叫做Party函数的类,它被调用OnMemberDeath().我已经创建了一个名为PlayerParty继承的新类Party,现在我只需要向OnMemberDeath( )函数添加两个但非常重要的行(下面的示例).是否可以仅覆盖部分方法?
派对类负责检测回合制战斗物.此外,每个缔约方都有成员(实体)和SelectionOrb(他们下面的小圈子).当一方成员去世时,必须选择新成员.通过成员选择过程,SelectionOrb必须接收新的父(AdjustWorldObject())以及必须分配对所选成员的引用(对于战斗内容).如果没有剩下活动成员,我们需要设置parent,null以便SelectionOrb不会与Member对象一起删除.
在PlayerParty类中有新对象,即CombatUI,它的作用与SelectionOrb基本相同(必须在当前死亡后接收新的父对象).希望这很清楚:).
/** in Party class **/
protected void OnMemberDeath( )
{
if( aliveCount > 1 )
{
AdjustWorldObject( );
aliveCount--;
}
else
{
ResetWorldObject( );
if( OnPartyDeath != null ) OnPartyDeath( ); // Event
else print( "Party died but event had no subscriptions!" );
}
}
/** in PlayerParty class **/
new void OnMemberDeath( )
{
if( aliveCount > 1 )
{ …Run Code Online (Sandbox Code Playgroud)