通过代码创建材料设计按钮

时间:2017-05-15 18:04:17

标签: java android material-design

我正在尝试以编程方式创建材质设计按钮。 (不是通过xml)

我正在尝试使用ButtonRectangle承包商,我收到了这个错误。

我的代码:

oldpath = "/myfolder/subfolderA/"
newpath = "/myfolder/subfolderB/"

#Ill be using the following variables as a parameter to a linux sed commmand which requires me to escape characters  
oldpath_sed = "\/myfolder\/subfolderA\/"
newpath_sed = "\/myfolder\/subfolderB\/"

command = "grep -rl {0} {1} | sudo xargs sed -i 's/{2}/{3}/g'"
newcommand = command.format(oldString,folderName,oldString_sed,newString_sed)

ps = subprocess.Popen(newcommand,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
output = ps.communicate()[0]

但是我收到了这个错误:

 AttributeSet attr = new AttributeSet() {
                    @Override
                    public int getAttributeCount() {
                        return 0;
                    }

                    @Override
                    public String getAttributeName(int index) {
                        return null;
                    }

                    @Override
                    public String getAttributeValue(int index) {
                        return null;
                    }

                    @Override
                    public String getAttributeValue(String namespace, String name) {
                        return null;
                    }

                    @Override
                    public String getPositionDescription() {
                        return null;
                    }

                    @Override
                    public int getAttributeNameResource(int index) {
                        return 0;
                    }

                    @Override
                    public int getAttributeListValue(String namespace, String attribute, String[] options, int defaultValue) {
                        return 0;
                    }

                    @Override
                    public boolean getAttributeBooleanValue(String namespace, String attribute, boolean defaultValue) {
                        return false;
                    }

                    @Override
                    public int getAttributeResourceValue(String namespace, String attribute, int defaultValue) {
                        return 0;
                    }

                    @Override
                    public int getAttributeIntValue(String namespace, String attribute, int defaultValue) {
                        return 0;
                    }

                    @Override
                    public int getAttributeUnsignedIntValue(String namespace, String attribute, int defaultValue) {
                        return 0;
                    }

                    @Override
                    public float getAttributeFloatValue(String namespace, String attribute, float defaultValue) {
                        return 0;
                    }

                    @Override
                    public int getAttributeListValue(int index, String[] options, int defaultValue) {
                        return 0;
                    }

                    @Override
                    public boolean getAttributeBooleanValue(int index, boolean defaultValue) {
                        return false;
                    }

                    @Override
                    public int getAttributeResourceValue(int index, int defaultValue) {
                        return 0;
                    }

                    @Override
                    public int getAttributeIntValue(int index, int defaultValue) {
                        return 0;
                    }

                    @Override
                    public int getAttributeUnsignedIntValue(int index, int defaultValue) {
                        return 0;
                    }

                    @Override
                    public float getAttributeFloatValue(int index, float defaultValue) {
                        return 0;
                    }

                    @Override
                    public String getIdAttribute() {
                        return null;
                    }

                    @Override
                    public String getClassAttribute() {
                        return null;
                    }

                    @Override
                    public int getIdAttributeResourceValue(int defaultValue) {
                        return 0;
                    }

                    @Override
                    public int getStyleAttribute() {
                        return 0;
                    }
                };

                Context c = getApplicationContext();
                ButtonRectangle btn = new ButtonRectangle(c, attr);

提前致谢。

0 个答案:

没有答案