这是我的问题,伙计们:
这是我编写的相关代码:
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.os.Bundle;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity
{
public void onButtonClick(View v){
Intent myIntent = new Intent(getBaseContext(),SecondActivity.class);
startActivity(myIntent);
}
public void onTitleOrHeaderClick(View v)
{
int length;
Intent intentToSecondActivity = new Intent(getBaseContext(),SecondActivity.class);
String tipHeader = v.getText(); /* for some reason getText() isn't recognized by the emulator */
intentToSecondActivity.putExtra("EXTRA_SESSION_ID","GOING to SecondActivity");
length = this.itemArray.tipObject.size();
for (int idx = 0; idx < length; idx++)
{
if(this.itemArray.tipObject.get(idx).get(1) == v.getText())
intentToSecondActivity.putExtra("EXTRA_SESSION_ID",v.getText());
}
}
}
答案 0 :(得分:0)
将v广播到Textview(标题和标题的类类型):
public void onTitleOrHeaderClick(View v){
int length;
TextView view=(TextView) v
Intent intentToSecondActivity = new Intent(getBaseContext(),SecondActivity.class);
String tipHeader = view.getText(); /* for some reason getText() is recognized now */
intentToSecondActivity.putExtra("EXTRA_SESSION_ID","GOING to SecondActivity");
length = this.itemArray.tipObject.size();
for (int idx = 0; idx < length; idx++){
if(this.itemArray.tipObject.get(idx).get(1) == view.getText())
intentToSecondActivity.putExtra("EXTRA_SESSION_ID",view.getText());
}
}