我正在尝试listView在我的应用程序中实现单个选择,以便一旦点击列表中的项目,按下的项目颜色状态就会与其他项目不同。我已经做了我所知道的一切,但效果并不好。问题是,即使我的实现在按下时更新每个项目的状态,它也不会将其他项目重置为其初始状态。
class BoxSelection{
bool isSelected;
String title;
String options;
BoxSelection({this.title, this.isSelected, this.options});
}
class _AddProjectState extends State<AddProject> {
List<BoxSelection> projectType = new List();
@override
void didChangeDependencies() {
super.didChangeDependencies();
projectType
.add(BoxSelection(title: "Building", isSelected: false, options: "A"));
projectType
.add(BoxSelection(title: "Gym House", isSelected: false, options: "B"));
projectType
.add(BoxSelection(title: "School", isSelected: false, options: "C"));
}
child: ListView.builder(
itemCount: projectType.length,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: () {
setState(() {
//here am trying to implement single selection for the options …Run Code Online (Sandbox Code Playgroud) 我有一个ImageView从服务器加载照片到它的Glide库。我有一个save按钮,我希望在加载后单击时将图像保存到图库和内部存储中。我尝试了几种可能性,但没有成功,因为单击按钮后似乎什么也没有发生。
public class ImagePreviewActivity extends AppCompatActivity {
ImageView imageView;
final File myDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/SmartPhoto");
boolean success = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_preview);
imageView = findViewById(R.id.image_preview);
saveImage();
}
private void saveImage() {
TextView mSave = findViewById(R.id.save_img);
mSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
final String fname = "image" + n + ".png";
myDir.mkdirs(); …Run Code Online (Sandbox Code Playgroud) 我使用flutter_masked_text来格式化我的控制器,以自动将千位分隔符添加到我的货币字段中。我正在用这个来实现这一目标。
var controller = new MoneyMaskedTextController(decimalSeparator: '.', thousandSeparator: ',');
Run Code Online (Sandbox Code Playgroud)
我不喜欢它的工作方式,因为它0.00从小数部分开始并自动开始添加数字。如果我输入1000,它应该变成1,000not 1,000.00。有没有办法可以格式化我的控制器字段以添加千位分隔符而无需小数分隔符?