我正在尝试在片段中添加一个TabHost ...代码是在下面给出的.在Fragment里面我试图添加TabHost来显示两个Tab
public class TablesFragment extends Fragment {
TabHost tabHost;
TabHost.TabSpec spec;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tables_fragment, container,
false);
tabHost = (TabHost) rootView.findViewById(android.R.id.tabhost);
tabHost.setup();
Intent intentAndroid = new Intent().setClass(getActivity(),
NewsFragment.class);
spec = tabHost.newTabSpec("Android").setContent(intentAndroid)
.setIndicator("Android");
tabHost.addTab(spec);
Intent intentBus = new Intent().setClass(getActivity(), NewsFragment.class);
spec = tabHost.newTabSpec("Welcome").setIndicator("Welcome")
.setContent(intentBus).setIndicator("Welcome");
tabHost.addTab(spec);
return rootView;
}
Run Code Online (Sandbox Code Playgroud)
}
这给了我错误...需要这个代码的助手......
logcat的:
01-26 16:21:27.092: E/AndroidRuntime(5597): FATAL EXCEPTION: main
01-26 16:21:27.092: E/AndroidRuntime(5597): java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'? …Run Code Online (Sandbox Code Playgroud) 从互联网文本数据加载并链接到图像.我无法理解如何在listview中加载图像.阅读,它需要使用毕加索或通用图像加载器,但不明白如何.请更正我的代码
public class JsonReadTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(params[0]);
try {
HttpResponse response = httpclient.execute(httppost);
jsonResult = inputStreamToString(
response.getEntity().getContent()).toString();
}
catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
private StringBuilder inputStreamToString(InputStream is) {
String rLine = "";
StringBuilder answer = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
try {
while ((rLine = rd.readLine()) != null) { …Run Code Online (Sandbox Code Playgroud) 有一个问题String有":"
String time = "21:45";
Run Code Online (Sandbox Code Playgroud)
如何将此字符串转换为两个int:
int hour = 21;
int minute = 45;
Run Code Online (Sandbox Code Playgroud)