情况
我正在尝试使用Webpack加载库.库本身已经使用Webpack分成多个块.
项目A依赖于项目B.项目B使用Webpack构建,包含多个块.项目A现在通过动态导入加载项目B. 构建项目A时,我希望在项目A的输出文件夹中创建项目B的块.
题
如何让项目B的块在项目的最终版本中保持为块状?
例
我做了一个示例项目(https://github.com/Robinfr/chunky-webpack),它有两个级别的子包.sub-package-a和b都创建了块,但是在构建main-package时它们都被篡改为一个main-bundle.js.
我想创建一个以随机顺序循环遍历数字0-8的for循环.请注意,每个号码只能访问一次.
我怎样才能做到这一点?
我正在开发一个Android应用程序,用户可以在其中编写/保存/修改潜在的大块文本.我相信单词的数量将在10-1000之间.在最糟糕的情况下,用户每天都会写一段新文本.
存储这些类型的文本数据的最佳方法是什么,考虑到能够轻松修改已保存的文本片段?
对于我的Android应用程序,我需要制作一个ViewID 数组.
该数组将保存81个值,因此逐个添加它们非常冗长.这就是它现在的样子:
cells[0] = R.id.Square00;
cells[1] = R.id.Square01;
cells[2] = R.id.Square02;
cells[3] = R.id.Square03;
cells[4] = R.id.Square04;
cells[5] = R.id.Square05;
//All the way to 80.
Run Code Online (Sandbox Code Playgroud)
是否有更短/更有效的方法?
我有一个函数f,它是这样的:
f = do
x1 <- g
x2 <- g
x3 <- g
...
xn <- g
return [x1,x2,x3,..., xn] --or (x1,x2,x3,..., xn)
Run Code Online (Sandbox Code Playgroud)
这需要很多行代码,我觉得这可以做得更漂亮.我想知道是否有办法做这样的事情:
f = do
[x,y,z] <- [g,g,g]
return [x,y,z]
Run Code Online (Sandbox Code Playgroud) 我刚开始学习C#.我看到一个老问题,有人试图制作可口可乐机器,这似乎是一个很好的练习.
但我陷入了金钱按钮.我无法弄清楚如何存储按钮在变量中所代表的金额,可通过ColaMachine方法访问.
我有以下代码:
using System;
using System.Windows.Forms;
using System.Drawing;
namespace QuickSharp
{
public class ColaMachine : Form
{
public ColaMachine()
{
this.Text = "Cola Machine";
this.Size = new Size(450 , 500);
//Money & Money Buttons
Label Money;
Money = new Label();
Money.Text = "Insert Coins Here:";
Money.Location = new Point(20, 100);
this.Controls.Add(Money);
Button MoneyButton1;
MoneyButton1 = new Button();
MoneyButton1.Text = "€0,05";
MoneyButton1.Location = new Point(28,125);
MoneyButton1.Click += new System.EventHandler(this.MoneyButton1_Click);
this.Controls.Add(MoneyButton1);
Button MoneyButton2;
MoneyButton2 = new Button();
MoneyButton2.Text = "€0,10";
MoneyButton2.Location …Run Code Online (Sandbox Code Playgroud) 首先,我创建了一个自定义视图,通过覆盖该onDraw()方法来吸引自己.事实证明这是不切实际的,因为我需要创建大量的视图.所以我创建了一个自定义的ViewGroup,它使用该onLayout()方法绘制每个子节点.
我在android文档中读到了子视图应该实现一个layout()方法.但是我创建的子视图使用onDraw方法绘制自己.我该怎么处理?我应该摆脱这种onDraw()方法吗?任何人都可以举例说明该layout()方法的工作原理以及我应该如何将我的onDraw()方法"转换" 为layout()方法?
我目前的onDraw()方法如下:
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
//Draw Border.
canvas.drawRect(mCellBounds, mBorderPaint);
//Draw Background.
canvas.drawRect(mBackgroundBounds, mBackGroundPaint);
//Draw Value if not 0.
if(Value != 0)
canvas.drawText(Integer.toString(Value), ValueX, ValueY, mNumberPaint);
//Draw Notes if Value == 0.
else
{
for(int i = 0 ; i < 9 ; i++)
if(NoteList[i])
canvas.drawText(Integer.toString(i), NoteX + ((i%3) * NoteMeasureX), NoteY + ((i/3) * NoteMeasureY), mNotePaint);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个存储在字符串中的十六进制数字(颜色),如下所示:"ff62e6b8".我需要将其转换回整数,以便我可以再次将其用作颜色值.我尝试过以下方法:
Int i = Integer.parseInt("ff62e6b8", 16);
Int i = Integer.valueOf("ff62e6b8", 16);
Int i = Integer.decode("ff62e6b8");
Run Code Online (Sandbox Code Playgroud)
但所有这些方法都会引发异常.我在这里错过了什么吗?
编译时出现以下错误:
CS0120:非静态字段,方法或属性'QuickSharp.CokeMachine.TotalInsertedCoins'需要对象引用
这是因为我正在尝试使用另一个类(CokeForm)中的TotalInsertedCoins变量.我怎样才能解决这个问题?如果我想在我的CokeForm方法中添加按钮,我会遇到同样的问题.
我的代码:
using System;
using System.Windows.Forms;
using System.Drawing;
namespace QuickSharp
{
public class CokeMachine
{
Button Coke;
Button Sprite;
Button Fanta;
Button RedBull;
Button Juice;
Button Water;
double CokeCost = 1.00;
double SpriteCost = 1.00;
double FantaCost = 1.00;
double RedBullCost = 2.50;
double JuiceCost = 2.00;
double WaterCost = 0.50;
Button Coin1;
Button Coin2;
Button Coin3;
Button Coin4;
Button Coin5;
Button Coin6;
double CoinAmount1 = 0.05;
double CoinAmount2 = 0.10;
double CoinAmount3 = 0.20;
double CoinAmount4 = …Run Code Online (Sandbox Code Playgroud)