我正在尝试制作一个应用程序,我想在其中将值从一个传递editText(MainActivity.java)到listView(bestFitActivity.java)另一个活动中。我的代码的问题是它只将一个值传递给listView. 当我输入一个新值时,它只会替换以前的值。
MainActivity.java
public class MainActivity extends AppCompatActivity {
int i = 0;
String getChunkSize;
ArrayList<String> chunkSizeArray = new ArrayList<>();
EditText chunkSize;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button chunkSave = (Button)findViewById(R.id.chunkSave);
Button processSave = (Button)findViewById(R.id.processSave);
Button bestFitDirector = (Button)findViewById(R.id.bestFitdirector);
Button worstFitDirector = (Button)findViewById(R.id.worstFitdirector);
Button firstFitDirector = (Button)findViewById(R.id.firstFitDirector);
EditText processSize = (EditText)findViewById(R.id.processSize);
chunkSize = (EditText)findViewById(R.id.chunkSize);
chunkSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
i++;
Log.d("Manager" , "%d" +i);
getChunkSize = chunkSize.getText().toString();
//Log.d("Manager" , "" +getChunkSize);
if(getChunkSize == null ) {
Toast.makeText(getBaseContext(), "Empty Input", Toast.LENGTH_SHORT).show();
}
}
});
bestFitDirector.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(MainActivity.this , bestFitActivity.class);
myIntent.putExtra("chunkSizeArray" , getChunkSize );
startActivity(myIntent);
}
});
}
PS:这段代码不完整
蓝山帝景
MYYA
相关分类