我需要用列做可编辑的表格,其中一列的宽度为 300dp,其他的为 100dp。我的活动代码:
ArrayList<String> data =new ArrayList<String> ();
GridView gvMain;
ArrayAdapter<String> adapter;
public void initList()
{
ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, R.layout.item3, R.id.editText1, data)
{
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item3, null);
}
final String theData = getItem(position);
final EditText editText = (EditText) convertView.findViewById(R.id.editText1);
editText.setText(theData);
editText.addTextChangedListener(
new MyTextWatcher(position)
);
return convertView;
}
};
gvMain.setAdapter(listAdapter);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.orp);
data=MyClass.GetData();
gvMain = (GridView) findViewById(R.id.gridView1);
initList();
}
}
现在 EditText 宽度取决于文本,但 gridview 列宽相同。如何为不同的列设置不同的大小。