我正在使用滑动标签作为导航来显示5个页面(片段),在应用程序菜单(3点)按钮中我想创建2个页面,1个用于设置,其他用于关于页面(只是静态文本)。请告诉我怎么能这样。
具体来说,当从菜单项中单击时,如何显示要显示的新片段(不在我的选项卡中)。
请帮助我,提前谢谢。
到目前为止这是我的代码。
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()){
case R.id.action_reset:
Unsafe.uhs1a.setSelection(0);
Unsafe.uhs1b.setSelection(0);
Unsafe.uhs1c.setSelection(0);
Precondition.phs1a.setSelection(0);
Precondition.phs1b.setSelection(0);
Precondition.phs1c.setSelection(0);
case R.id.action_about:
// need to open a static page ( fragment) here
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
答案 0 :(得分:0)
不确定这是否是您想要的,但我有一个片段可以打开一个新的Actvity(里面有一个片段):
public boolean onOptionsItemSelected(MenuItem item)
{
switch(item.getItemId())
{
case R.id.action_about:
Intent intent_to = new Intent(getActivity(),MyNewActivity.class);
startActivity(intent_to);
break;
}
return true;
}
在MyNewActivity
内部,你应该有一个容器并使用getFragmentManager()
如果您想根据新片段关闭的方式做某事,您甚至可以使用startActivityForResult
希望有所帮助
答案 1 :(得分:0)
旧问题,但WTH。您使用$k = $_GET["q"];
$con = mysqli_connect("localhost", "root", "");
mysqli_select_db($con,"x");
$terms=explode(" ",$k);
$i=0;
$set_limit = ("9");
$subi = "";
foreach ($terms as $each)
{
$i++;
$escapedSearchString = mysqli_real_escape_string($con,$each);
if ($i == 1 )
$subi.= " title LIKE '%$escapedSearchString%' ";
else
$subi.= " AND title LIKE '%$escapedSearchString%' ";
}
$query = "select SQL_CALC_FOUND_ROWS * from table WHERE $subi order by rand() limit $set_limit";
$qry = mysqli_query($con,"$query");
$row_object = mysqli_query($con,"Select Found_Rows() as rowcount");
$row_object = mysqli_fetch_object($row_object);
$actual_row_count = $row_object->rowcount;
$result = $actual_row_count;
和她的朋友FragmentManager
执行此操作:
FragmentTransaction