appBar iconStyleRight语法错误

时间:2016-01-17 03:15:31

标签: material-ui

我有

private class AsyncDataClass extends AsyncTask<String, Void, String> {


        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected String doInBackground(String... params) {
            try {
                URL url = new URL(params[0]);
                HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
                httpURLConnection .setRequestMethod("POST");
                httpURLConnection .setDoInput(true);
                httpURLConnection .setConnectTimeout(1000 * 6);
                httpURLConnection .setReadTimeout(1000 * 6);

                //InputStream to get response
                InputStream IS = httpURLConnection .getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(IS, "iso-8859-1"));
                StringBuilder response = new StringBuilder();
                String json;
                while( (json = bufferedReader.readLine()) != null){
                    response.append(json + "\n");
                    break;
                }
                bufferedReader.close();
                IS.close();
                httpURLConnection .disconnect();
                return response.toString().trim();

            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;


        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            System.out.println("Resulted Value: " + result);
            if(result.equals("") || result == null){
                Toast.makeText(RegisterActivity.this, "ERROR", Toast.LENGTH_LONG).show();
            }
            int jsonResult = returnParsedJsonObject(result);

            if(jsonResult == 1){
                //PARSE DATA here;
            }
        }
    }

    private int returnParsedJsonObject(String result){
        JSONObject resultObject = null;
        int returnedResult = 0;
        try {
            resultObject = new JSONObject(result);
            if ( resultObject.length() > 0 ){
returnedResult = 1;
} else {
returnedResult = 0;

}
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return returnedResult;
    }

但是iconStyleRight给了我错误

render() {
    return <AppBar style={{ position: "fixed" }} title={<span>my Title</span>}

        iconElementLeft={<IconButton><NavigationMenu /></IconButton>}
        iconStyleRight={{color:"red"}}
        iconElementRight={<IconButton><span className = "material-icons">account_circle</span></IconButton>}
        />
}

不知道为什么。我尝试了很多种方法,包括在Type '{ [x: number]: undefined; color: any; }' is not assignable to type 'string' 元素中添加style,这会被忽略。

非常感谢使这个正确的图标显示为红色的正确语法,以便我可以理解如何将样式应用于我的图标。

1 个答案:

答案 0 :(得分:0)

事实证明,解决方案是设置IconButton组件的iconStyle属性。

同样在我的当前环境中,在material-ui.d.ts中,iconStyleRight属性的typedef被错误地设置为&#39; string&#39;,但应该是对象,使问题复杂化。

现在好了。