我在活动A中有一个整数数组:
int array[] = {1,2,3};
Run Code Online (Sandbox Code Playgroud)
我想将该变量发送到活动B,因此我创建了一个新的intent并使用了putExtra方法:
Intent i = new Intent(A.this, B.class);
i.putExtra("numbers", array);
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
在活动BI中获取信息:
Bundle extras = getIntent().getExtras();
int arrayB = extras.getInt("numbers");
Run Code Online (Sandbox Code Playgroud)
但这并不是真的发送数组,我只是在arrayB上得到值'0'.我一直在寻找一些例子,但我没有发现任何事情.
我有一个与标题错误有关的问题.我正在使用c#和Visual Studio 2010.
我有一个声明为"公共类FormularioGeneral:Form"的表单,它是我的应用程序中其余表单的基础.当我尝试访问Designer视图时,我会多次出现此错误,如图所示:
所有错误都引用InitializeComponent方法中的行,其中值被赋予像这样的属性:
[...]
this.PanelMargenIzquierdoCapaBase.BackColor = m_ColorCapaBase;
[...]
Run Code Online (Sandbox Code Playgroud)
但是所有变量都在与只读属性相同的类中声明,并且所有变量都在构造函数中调用的方法内分配.
财产声明:
protected Color m_VariableName;
public Color VariableName
{
get { return m_VariableName; }
set { }
}
Run Code Online (Sandbox Code Playgroud)
构造函数代码:
public FormularioGeneral()
{
ConfigurarUI();
AccionesConstructor();
InitializeComponent();
PostInicializacionComponentes();
EstablecerIcono();
InicializarLocalizacionFormulario();
}
Run Code Online (Sandbox Code Playgroud)
ConfigurarUI方法:
public virtual void ConfigurarUI()
{
[...]
m_AltoBordeSuperiorCapaBase = 30;
m_AltoBordeInferiorCapaBase = 7;
m_AnchoBordesLateralesCapaBase = 7;
m_ColorCapaBase = Color.FromArgb(50, 100, 150);
m_ColorTextoCapaBase = Color.White;
m_ColorTextoBotonAplicacion = Color.Black;
m_FuenteTextoIzquierdoCapaBase = new System.Drawing.Font("Verdana", 11.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
m_FuenteTextoCentroCapaBase = new System.Drawing.Font("Verdana", 14.0F, System.Drawing.FontStyle.Bold, …Run Code Online (Sandbox Code Playgroud) 我有一些麻烦试图将信息存储在我的数据库中并在ListView中显示它.
这是我想要显示行的ListActivity:
public class Prueba extends ListActivity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.i_prueba);
DataBaseAccess db = new DataBaseAccess(this);
db.open();
Cursor result = db.getAllContact();
startManagingCursor(result);
// the desired columns to be bound
String[] columns = new String[] {"_id", "nombre", "telefono", "mail"};
// the XML defined views which the data will be bound to
int[] to = new int[] { R.id.textid, R.id.textNombre, R.id.textTelefono, R.id.textMail };
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, R.layout.i_listadb, …Run Code Online (Sandbox Code Playgroud) 我正在用C++编写一个程序来提高效率.
基本上我只是创建一个巨大的整数向量(1 GB)并用随机数填充它.我没有线程执行程序并计算所需的时间.
现在我想使用2个线程并查看时间改进,但程序花费的时间比2个线程要多.不知道我做错了什么:S
#includes...
using namespace std;
//This function just make a for from first to final. Each iteration write a random
//number in the position i of the vector
void generateRandomVector(vector<int> &vec,int first, int final);
//Inside this function i take timestamp2 and calculate the executing time
void calculateTime(clock_t start);
int main(int argc, char *argv[]){
clock_t start;
double logaritmo;
int n = 256*1024*1024;
//Taking timestamp 1
start = clock();
vector<int> vec(n);
thread t1(generateRandomVector, ref(vec), 0, n/2);
thread t2(generateRandomVector, ref(vec), …Run Code Online (Sandbox Code Playgroud) 在过去的几天里,我一直在阅读C#中的属性和方法之间的差异,以及何时使用它们.我读到的大多数文章/问题都说吸气剂应该是"轻巧的",并且内部永远不会有大量的逻辑或复杂的操作.
现在我有一个get我认为在属性和方法之间的界限,所以我想看看你们都在想什么,如果我应该改变方法或留在吸气剂.
还欢迎任何其他建议:D
public decimal[] getPreprocData
{
get
{
int i = 3;
decimal[] data = new decimal[9];
data[0] = (start.Value.Hour * 3600) + (start.Value.Minute * 60);
data[1] = duration.Value;
data[2] = flowRate.Value;
foreach (NumericUpDown nud in gbHTF.Controls.OfType<NumericUpDown>().OrderBy(nud => nud.TabIndex))
{
data[i] = nud.Value;
i++;
}
return data;
}
}
Run Code Online (Sandbox Code Playgroud)