在网上竟然很少这个完整的例子, 我这里做一个例子让大家分享一下
MainActivity.java
package com.example.actionbarmenu;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.ActionBar.TabListener;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ActionBar ab = getActionBar();
// set defaults for logo & home up
ab.setDisplayHomeAsUpEnabled(false);
ab.setDisplayUseLogoEnabled(false);
// 设置AcitonBar的操作模型
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// 将Activity的头部去掉
ab.setDisplayShowTitleEnabled(false);
ab.addTab(ab.newTab().setText("Tab-A").setTabListener(new TabLister(new FragmentA())));
ab.addTab(ab.newTab().setText("Tab-B").setTabListener(new TabLister(new FragmentB())));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
private class TabLister implements TabListener{
private Fragment fragment;
TabLister(Fragment fragment){
this.fragment = fragment;
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
//ft.add(R.id.context, fragment);
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
ft.add(R.id.context, fragment);
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
ft.remove(fragment);
}
}
private class FragmentA extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
return inflater.inflate(R.layout.activity_main_fragment_a, container, false);
}
}
private class FragmentB extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
return inflater.inflate(R.layout.activity_main_fragment_b, container, false);
}
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<FrameLayout
android:id="@+id/context"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true">
</FrameLayout>
</RelativeLayout>activity_main_fragment_a.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/fragmentA"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1111111" />
</FrameLayout>
</LinearLayout>activity_main_fragment_b.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/fragmentA"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2222222" />
</FrameLayout>
</LinearLayout>第一次用phonegap封装ios app
1. 用sencha 代码替代了phonegap生成的www文件夹文件,编译无法通过
解决: 不能用sencha完全替代phonegap的代码,需要在index.html中加入
<script type="text/javascript" src="/blog_article/js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
2. 在xcode中需要导入证书,然后achieve build
具体参看http://blog.csdn.net/zltianhen/article/details/6946848
3. 发布成为ipa,发现没有上文说到的share按钮
解决:原来是Distribute...-->save for enterprise or ad-hoc deployment
就可以达到原来share按钮的效果...
错误提示:
<Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Fatal Internal error: java.lang.InternalError: Can’t connect to window server – not enough permissions.
Build step ‘Execute shell’ marked build as failure
Finished: FAILURE
分析原因:因为是在signing那步出现的问题,结合“Can’t connect to window server”这句提示,推断是因为Jenkins默认以daemon用户身份运行,而daemon的权限限制还是蛮多的,像前台窗口这样的访问权限很可能是没有的,故而导致以上问题。
解决办法:有了以上的分析,也就比较明确了:修改Jenkins配置,使其以普通用户身份运行。
依次运行下面的命令:
注:更好的实践是新建一个叫做jenkins的user和对应的group,以其运行Jenkins。自己当前用户的用户名可以通过运行’id’命令查看,替换掉上面示例命令中的bixiaopeng即可。
ok, 刷新浏览器查看效果
username修改失败解决
如果还是有错,可能是user没有修改成功,那我们去看一下:
#1.查看Usr
#2.打开文件,查看usr
#3.如果username 不是你的用户名,就到此文件夹下面打开org.jenkins-ci.plist文件
#4.修改成功后会要求你root权限,输入后修改成功
本文链接:【持续集成】Mac上使用Jenkins持续集成报错Can't connect to window server - not enough permissions.
转载声明:本站文章若无特别说明,皆为原创,转载请注明来源:WirelessQA,谢谢!^^