描述:在我的mainActivity
班级中,我添加了一个带有文本的标题和功能区,并将其发送到其他secondActivity
班级以onclick
使用addRow(rootLayout, length,buttonHeight)
. 我的要求是,如果我们单击我们在课堂上添加的任何行secondActivity
,我必须更改我们在mainActivity
课堂上添加的功能区文本。
有人可以帮忙吗?
code:
MainActivity.java
-----------------
/*Main Activity Class which consists ribbon text and called method for creating the second row*/
public class MainActivity extends Acitvity{
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.mainView); **//Main view**
final FrameLayout rootLayout = (FrameLayout)findViewById (R.id.mainViewRootLayout);
FrameLayout ribbonLayout = (FrameLayout)findViewById(R.id.mainribbonLayout);
TextView ribbonText = (TextView)findViewById(R.id.mainribbonLayoutText);
ribbonText.setText("MainRibbonViewBeforeClick");
LayoutInflater inflater = (LayoutInflater)getSystemService (context.Layout_Inflater_service);
addRow(rootLayout);
}
}
/*Here is the calling method in same class which adds one more text view, if we click on text view the ribbon text of oncreate method has to be changed*/
public void addRow(FrameLayout rootLayout)
{
Rect rect = new Rect();
rootLayout.getDrawingRect(rect);
FrameLayout ribbonLayout = (FrameLayout)findViewById(R.id.subRibbonLayout);
TextView subText = (TextView)findViewById(R.id.subribbonLayoutText);
subText.setText("ClicktoChangeTheRibbon");
subText.setOnclickListener(new onClickListener() **//Setting up the listener
{
public vid onclick(View v){
/*Here I need to implement a code that changes the ribbon text which I have added in onCreate method*/
}
});
}
}
请查看上面的代码并建议我解决方案。