我試圖傳遞變量「stockSymbol」在我的項目,這部分設置使用...傳遞變量通過Android項目
ticker.setText("Stock Ticker is: " + stockSymbol);
成爲我的項目的一部分相同的值。 ..
final String yqlURL = yahooURLFirst + stockSymbol + yahooURLSecond;
下面是完整的代碼...
String stockSymbol = "";
...
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stock_info);
stock = (EditText) findViewById(R.id.stock);
ticker = (TextView) findViewById(R.id.ticker);
btnquote = (Button) findViewById(R.id.btnquote);
btnquote.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// get the name from edittext and storing into string variable
String stockSymbol = stock.getText().toString();
// binding name to the textview
ticker.setText("Stock Ticker is: " + stockSymbol);
}
});
// Initialize TextViews
companyNameTextView = (TextView) findViewById(R.id.companyNameTextView);
yearLowTextView = (TextView) findViewById(R.id.yearLowTextView);
yearHighTextView = (TextView) findViewById(R.id.yearHighTextView);
daysLowTextView = (TextView) findViewById(R.id.daysLowTextView);
daysHighTextView = (TextView) findViewById(R.id.daysHighTextView);
lastTradePriceOnlyTextView = (TextView) findViewById(R.id.lastTradePriceOnlyTextView);
changeTextView = (TextView) findViewById(R.id.changeTextView);
daysRangeTextView = (TextView) findViewById(R.id.daysRangeTextView);
// Sends a message to the LogCat
Log.d(TAG, "Before URL Creation " + stockSymbol);
// Create the YQL query
final String yqlURL = yahooURLFirst + stockSymbol + yahooURLSecond;
這不是如何顯示有關您的問題的更多信息。你需要通過編輯你現有的問題來顯示更多,__uneditted__代碼(預問題)。此外,通過評論他們的答案告訴人們,這不起作用。 – Phil
請不要用答案來回答其他答案。編輯原始帖子或使用評論 – Nick