我的SlidingScreenActivity代码是,
private class SlideMenuClickListener implements
ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// display view for selected nav drawer item
displayView(position);
}
}
public void displayView(int position) {
Fragment fragment = null;
switch (position) {
case 0:
mDrawerLayout.closeDrawer(mDrawerList);
break;
case 1:
fragment=new HomeFragment();
break;
case 2:
fragment=new Mywallet();
break;
case 3:
fragment=new AboutUsFragment();
break;
default:
break;
}
}
if (fragment != null) {
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
mDrawerList.setItemChecked(position, true);
mDrawerList.setSelection(position);
setTitle(navMenuTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
} else {
mDrawerLayout.closeDrawer(mDrawerList);
Log.e("SlidingMainActivity", "Error in creating fragment");
}
}
另一个Activity按钮侦听器
btnWallet.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent mIntent=new Intent(this,SlidingScreenActivity.class);
startActivity(mIntent);
}
});
我如何打开我在案例2中已经声明的MyWallet fragment
:在SlidingScreenActivity.class
中,当通过Intent点击另一个活动中的按钮时?
有人可以帮帮我吗?
提前致谢...
答案 0 :(得分:1)
SlidingScreenActivity:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class DestroyPlayerOnTouch : MonoBehaviour {
public GameObject panel;
bool hasshield = false;
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Monster" && !hasshield)
{
panel.SetActive (true);
}
else if(col.gameObject.tag == "Monster" && hasshield)
{
panel.SetActive (false);
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Shield")
{
Debug.Log("hasshield!");
hasshield = true;
}
}
}
另一个Activity按钮侦听器:
@Override
protected void onStart() {
super.onStart();
displayView(getIntent().getIntExtra("position", 2));
}