小编ReN*_*eNa的帖子

26
推荐指数
3
解决办法
5万
查看次数

Android删除tabwidget中选项卡之间的空格

我已经制作了一个应用程序,其中包含HelloTabActivity中的标签,这些标签之间也有空格,任何人都可以建议如何删除此空间,并且标签下方还有一条灰色线条如何删除?

在此输入图像描述

main.xml中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp" >
        <HorizontalScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scrollbars="none">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </HorizontalScrollView>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomTheme" parent="@android:style/Theme">
    <item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget">
    <item name="android:textAppearance">@style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" 
    parent="@android:style/TextAppearance.Widget.TabWidget">
    <item name="android:textSize">10sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textColor">#1589FF</item>
    <item name="android:padding">3dip</item>
</style>


</resources>
Run Code Online (Sandbox Code Playgroud)

活动

public class InfralineTabWidget extends TabActivity{

public void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud)

android tabwidget android-layout android-style-tabhost android-tabhost

11
推荐指数
2
解决办法
3万
查看次数

将html标记存储在xml中

我有一个带有各种html标签的html格式的String.我想把这个字符串放在xml标签中,以便html标签保留.例如

public class XMLfunctions {

    public final static Document XMLfromString(String xml){

        Document doc = null;

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                try {

            DocumentBuilder db = dbf.newDocumentBuilder();

            InputSource is = new InputSource();
            is.setCharacterStream(new StringReader(xml));
            doc = db.parse(is); 

        } catch (ParserConfigurationException e) {
            System.out.println("XML parse error: " + e.getMessage());
            return null;
        } catch (SAXException e) {
            System.out.println("Wrong XML file structure: " + e.getMessage());
                        return null;
        } catch (IOException e) {
            System.out.println("I/O exeption: " + e.getMessage());
            return null;
        }

            return doc;

    }


    /** Returns …
Run Code Online (Sandbox Code Playgroud)

html java xml

7
推荐指数
1
解决办法
5421
查看次数

AsyncTask onPreExecute progressdialog

当onPreExecute函数执行时,我有一个AsyncTask,它给了我一个例外

**java.lang.IllegalStateException:查看com.android.internal.policy.impl.PhoneWindow$DecorView@44ea0e20已添加到窗口管理器中.**

当progressDialog的show()方法被调用时.

我的活动

public class TopNewsActivity extends ListActivity {

public static final String LOG_TAG = "Infra";
private ProgressDialog progressDialog;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listplaceholder);
    new BackgroundAsyncTask().execute();
}

public class BackgroundAsyncTask extends AsyncTask<String, Integer, ArrayList<HashMap<String, String>>> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        progressDialog = new ProgressDialog(TopNewsActivity.this);
        progressDialog.setCancelable(true);
        progressDialog.setMessage("Loading...");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setProgress(0);
        progressDialog.show();
    }

    @Override
    protected ArrayList<HashMap<String, String>> doInBackground(String... paths) {
        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

        String …
Run Code Online (Sandbox Code Playgroud)

android android-asynctask

7
推荐指数
1
解决办法
3万
查看次数

SQL查询计数频率

我有一张桌子,里面有条目

id     keywords
1      cat, dog, man, mouse
2      man, pen, pencil, eraser
3      dog, man, friends
4      dog, leash,......
Run Code Online (Sandbox Code Playgroud)

我想做一张像桌子的东西

id  cat  dog  man  mouse  pen  pencil  eraser  friends  leash ......
1   1    1    1    1      0    0       0       0        0
2   0    0    1    0      1    1       1       0        0
3   0    1    1    0      0    0       0       1        0
Run Code Online (Sandbox Code Playgroud)

等等.

sql t-sql sql-server pivot

3
推荐指数
1
解决办法
3346
查看次数

使用SimpleAdapter在Android ListView中自定义Typface

任何人都可以告诉我如何将listview的字体更改为arial我无法弄明白.

以下是我的代码:

public class TopNewsActivity extends ListActivity {

public static final String LOG_TAG = "Infra";
private ProgressDialog progressDialog;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listplaceholder);
    new BackgroundAsyncTask().execute();
}

public class BackgroundAsyncTask extends AsyncTask<String, Integer, ArrayList<HashMap<String, String>>> {

    @Override
    protected void onPreExecute() {
        progressDialog = new ProgressDialog(TopNewsGroup.group);
        progressDialog.setCancelable(true);
        progressDialog.setMessage("Loading...");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setProgress(0);
        progressDialog.show();
    }

    @Override
    protected ArrayList<HashMap<String, String>> doInBackground(String... paths) {

        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

        String xml …
Run Code Online (Sandbox Code Playgroud)

android android-listview typeface

3
推荐指数
1
解决办法
5094
查看次数

Android setOnItemClickListener

我无法启动" OnItemClickListener ".

你可以看到我的代码片段

 ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main, new String[] { "title"}, new int[] { R.id.item_title});
    setListAdapter(adapter);

    final ListView lv = getListView();
    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              
            @SuppressWarnings("unchecked")
            HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position);                   
            Toast.makeText(TopNewsActivity.this, "ID '" + o.get("id") + "' was clicked.", Toast.LENGTH_LONG).show(); 

        }
    });
Run Code Online (Sandbox Code Playgroud)

在setListAdapter之后,我的调试器转到" lv.setOnItemClickListener "但是然后没有进入循环并移出.

我想让链接Clickable友好帮助.

android android-listview

2
推荐指数
2
解决办法
2万
查看次数

列表视图中的Android OnItemClickListener无法正常工作

我已经制作了一个标签活动,当我点击特定标签时,我可以扩展列表活动并且我也获得列表视图,但我无法使列表中的项目可点击.码:

package com.infra.android.views;

import java.util.ArrayList;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class TopNewsActivity extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listplaceholder);

        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();


        String xml = XMLfunctions.getTopNewsXML();
        Document doc = XMLfunctions.XMLfromString(xml);

        int numResults = XMLfunctions.numResults(doc);

        if((numResults <= 0)){
            Toast.makeText(TopNewsActivity.this, "No Result Found", …
Run Code Online (Sandbox Code Playgroud)

android android-listview

2
推荐指数
1
解决办法
1万
查看次数

listview中的Android onItemClicklistener无法正常工作

任何人都可以帮我解决我的问题.我有一个TabActivity每个标签触摸打开一个新的活动,这个扩展ListActivity这时我得到我希望通过使用OnItemClickListener可点击的所需项目的列表.

我正在附上我的main.xml,请通过它告诉我是否需要进行任何更改

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="5dp"/>
            <TextView  
                android:id="@+id/item_title"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:padding="2dp"
                android:textSize="20dp" />
            <TextView  
                android:id="@+id/item_subtitle"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
                android:padding="2dp"
                android:textSize="13dp" />
        </LinearLayout>
    </TabHost>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

活动

public class TopNewsActivity extends ListActivity
{

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listplaceholder);

        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); …
Run Code Online (Sandbox Code Playgroud)

android

2
推荐指数
1
解决办法
1万
查看次数