我知道这一定很简单。但对于我的一生,我不知道为什么我不能把这件事做好。
好的,所以我想从 ListView 页面进入(明白了),然后单击一个开关使其进入下一页(也明白了。)然后我想要一个 int 来告诉我我在表单中的哪个位置最后一页(可能有效?)现在我无法让 If Else 语句在该页面中工作。
public class NightmareParts extends Activity
{
public int current_AN_Number = NightmareList.AN_position_num;
private TextView edit_title;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.part_layout);
// isn't working here. Why?
// test_edit = (TextView)findViewById(R.id.directions_tv);
// test_edit.setText(R.string.directions_text_two);
// works without this being in here.
setDoneButtonListener();
}
//Set up the Done button to initialize intent and finish
private void setDoneButtonListener()
{
Button doneButton = (Button) findViewById(R.id.back_button);
doneButton.setOnClickListener (new View.OnClickListener() {
@Override
public void onClick(View v)
{
finish();
}
});
}
private void editTitle()
{
if (current_AN_Number = 1)
{
edit_title = (TextView)findViewById(R.id.part_title);
edit_title.setText(R.string.AN_title_1);
}
}
}
current_AN_number 来自最后一页。
最佳答案
您的 if
语句不正确:
if (current_AN_Number = 1)
当您想将赋值运算符与 ==
运算符进行比较时,您已经使用了赋值运算符:
if (current_AN_Number == 1)
关于java - 无法让我的 if 语句发挥作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20436170/