小编Fol*_*lyd的帖子

如何获得片段宽度?

这是我的布局.我需要在CategoryFragment中获取宽度.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/category_list"
        android:layout_width="150dp"
        android:layout_height="match_parent"
        android:background="@color/white_background"
        android:orientation="vertical" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:text="@string/pianodule_list"
            android:textSize="16sp" />

        <com.handmark.pulltorefresh.library.PullToRefreshListView
            android:id="@id/refreshable_listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:choiceMode="singleChoice"
            android:descendantFocusability="beforeDescendants"
            android:divider="@null" />
    </LinearLayout>

    <View
        android:layout_width="0.1dp"
        android:layout_height="match_parent"
        android:background="@color/divider_line" />

    <fragment
        android:name="com.srefu.frag.CategoryFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:tag="category" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

所以在CategoryFragment的onViewCreated()中我尝试了几种方法来实现它,但一切都行不通.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    View v = view;
    // View v = getView(); 
    int w1 = v.getWidth(); //return 0
    int w2 = v.getLayoutParams().width; //return NullPointerException
    int w3 = v.getMeasuredWidth(); //return …
Run Code Online (Sandbox Code Playgroud)

android fragment android-fragments

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

ElasticSearch无法找到分析仪?

我在elasticsearch.yml中配置了我的全局自定义分析器,这是我的配置:

index :
analysis :
    analyzer :
        titleAnalyzer :
            type : custom
            tokenizer : ik_max_word
            filter : [titleSynoymFilter, englishStemmerFilter]
    filter :
        titleSynoymFilter :
            type : synonym
            synonyms_path : ../analysis/title_synonym.txt
        englishStemmerFilter :
            type : stemmer
            name : english
Run Code Online (Sandbox Code Playgroud)

然后我通过运行命令测试我的分析器 $ echo 'A drop in the ocean'| http :5600/_analyze?analyzer=titleAnalyzer

但elasticsearch告诉我它找不到分析仪:

{
"error": {
    "reason": "failed to find analyzer [titleAnalyzer]",
    "root_cause": [
        {
            "reason": "[elastisearch][127.0.0.1:9300][indices:admin/analyze[s]]",
            "type": "remote_transport_exception"
        }
    ],
    "type": "illegal_argument_exception"
},
"status": 400
}
Run Code Online (Sandbox Code Playgroud)

elasticsearch elasticsearch-plugin elasticsearch-2.0

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