Add CustomView to ToolBar [make search bar]
Hi guys in this article I will show you how to add CustomView to your ToolBar in Sketchware
- Enabling appcompat library
- Create a new CustomView
- Design your CustomView for me I added edittext1 & button1
- Add this code
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
View logo = getLayoutInflater().inflate(R.layout.dvv, null);
logo.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT));
_toolbar.addView(logo);
final Button button1 = (Button)logo.findViewById(R.id.button1);
final EditText edittext1 = (EditText)logo.findViewById(R.id.edittext1);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
SketchwareUtil.showMessage(getApplicationContext(), edittext1.getText().toString());
}
});
Follow this video to understand more
Where's the video?
ReplyDelete