我想从另一个类中隐藏或更改浮动操作按钮,但我无法成功。有人可以帮我吗?
MainActivity.java
public class MainActivity extends AppCompatActivity {
private WebView mywebview;
@Override
protected void onCreate(Bundle savedInstanceState) {
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Some onclick action
}
});
}
WebAppInterface.java
public class WebAppInterface {
Context mContext;
/** Instantiate the interface and set the context */
WebAppInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
@JavascriptInterface
public void showToast(String toast) {
if (toast=="hide") {
fab.setVisibility(View.GONE);
} else if (toast=="change") {
// update src.Compat command ?
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// new onclick action
}
}
}
}