Android layout 导入什么来解决问题;LayoutParams无法解析为变量";?
我发现错误Android layout 导入什么来解决问题;LayoutParams无法解析为变量";?,android-layout,layoutparams,resolve,Android Layout,Layoutparams,Resolve,我发现错误LayoutParams无法解析为一行代码上的变量,如下tv.setLayoutParams(新GridView.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,0.1f)) 当我按ctrl+shift+o导入必要的包时,我会得到很多版本的包作为选项。我不知道该由谁来做这项工作。 我有什么选择 导入后导入android.app.ActionBar.LayoutParams仍然是get错误 The cons
LayoutParams无法解析为一行代码上的变量,如下tv.setLayoutParams(新GridView.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,0.1f))代码>
当我按ctrl+shift+o导入必要的包时,我会得到很多版本的包作为选项。我不知道该由谁来做这项工作。
我有什么选择
导入后导入android.app.ActionBar.LayoutParams代码>仍然是get错误
The constructor AbsListView.LayoutParams(int, int, float) is undefined
可以通过导入[any layout].LayoutParams来解决此问题
如。
导入android.widget.GridLayout.LayoutParams代码>
虽然我不清楚选择导入哪个包的标准是什么。
解决问题
the constructor AbsListView.LayoutParams(int, int, float) is undefined
确保第三个参数也是“int”
应该是:
LayoutParams cannot be resolved to a variable on a line of code which is as follows tv.setLayoutParams(new GridView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
只需添加以下语句即可将LayoutParams与LinearLayout一起使用:
import android.widget.LinearLayout;
然后您可以轻松编写以下代码:
LinearLayout ll1;
LayoutParams params1;
/*Creating a linear layout*/
ll1=new LinearLayout(this);
ll1.setOrientation(LinearLayout.VERTICAL);
/*set the width and height of the linear layout*/
params1=new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
setContentView(ll1,params1);