0

描述:在我的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*/  
                 }  
            });  
          }  

}

请查看上面的代码并建议我解决方案。

4

1 回答 1

0

创建一个静态变量,将功能区的文本值分配给它。在第二个活动类中的任何行的单击事件上,将变量的值更改为要为功能区文本显示的值。

于 2013-09-01T08:58:52.607 回答