我正在尝试传递在我的项目的这一部分中设置的变量“stockSymbol”...
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;