我的“findViewById”有问题,它发生在线路之间。
new AlertDialog.Builder(DetailShareHoldingActivity.this).setTitle("Köp " + Portfolio.getPortfolio().getShareHolding(positionList).getName() + " Aktier").setView(addView).setPositiveButton("Köp", new DialogInterface.OnClickListener() {
和线
public void onClick(DialogInterface dialog, int whichButton) {
如果我将线放在其他任何可以正常工作的地方,问题是我必须将线放在我拥有的地方,所以我不知道为什么它会抱怨?这是我的 OnclickListener
buyButton = (Button)findViewById(R.id.buyButton);
buyButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
EditText tempEditText;
final View addView = getLayoutInflater().inflate(R.layout.shop_exsisting_share, null);
new AlertDialog.Builder(DetailShareHoldingActivity.this).setTitle("Köp " + Portfolio.getPortfolio().getShareHolding(positionList).getName() + " Aktier").setView(addView).setPositiveButton("Köp", new DialogInterface.OnClickListener() {
tempEditText = (EditText)findViewById(R.id.nrOfSharesInPortfolioEdit);//Complains on findViewById "Return type for the method is missing" and I have to have the code exactly here so that it is visible when the dialog is created and not when the button is pressed.
tempEditText= (EditText) findViewById(R.id.nrOfSharesInPortfolioEdit);
tempEditText.setText(Portfolio.getPortfolio().getShareHolding(positionList).getNrOfSharesInPortfolio());
System.out.println(Portfolio.getPortfolio().getShareHolding(positionList).getNrOfSharesInPortfolio());
tempEditText= (EditText) findViewById(R.id.currentCourseEdit);
tempEditText.setText(Double.toString(Portfolio.getPortfolio().getShareHolding(positionList).getCurrentRate()));
public void onClick(DialogInterface dialog, int whichButton) {
System.out.println("Button pressed köp ");
}
}).setNegativeButton("Avbryt", null).show();
}
});