Tech Programming Ideas is one of the best places on the programming for programmers. Learn coding with Tech Programming Ideas tutorials. We are covered android programming, php, yii2 framework, javascript, mysql, vb.net etc.
Android action bar was used to maintain a consistent navigation across the application. Menu list button show on action bar.
Screen shot
Android - Navigation
Overview of Action Bar
Action bar mainly contains four functional areas. They are app icon, view control, action buttons and action overflow. App Icon – App branding logo or icon will be displayed here. View Control – A dedicated space to display app title. Also provides option to switch between views by adding spinner or tabbed navigation. Action Buttons – Some important actions of the app can be added here. Action Overflow – All unimportant action will be shown as a menu.
Here the important xml attributes should be known are
android:icon – Defines the icon of the action item. android:title – Title for the icon. android:showAsAction – Defines the visibility of the action item. It accepts following values.
ifRoom
Displays the icon if there is space available on the screen
never
Never places this icon on the action bar
always
Forces to display the icon always irrespective of space available. This way is not suggested.
withText
Displays a text along with the icon. Normally the text value defined by android:title will be displayed
collapseActionView
Defines the action layout associated with it. This action view defined usingandroid:actionLayout or android:actionViewClass
Example
Add menu title set as res/values/strings.xml <resources> .... <string name="entries">ENTRIES</string> <string name="entrieslist">ENTRIES LIST</string> <string name="salesreport">SALES REPORT</string> <string name="logout">LOGOUT</string> </resources>
Create a new xml file under res ⇒ menu named main_actions.xml and add the following code.
Now open your main activity class and do the following in onCreateOptionsMenu() method.
public class RptsalesreportActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_rptsalesreport); ............... } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_actions, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.entries: // code here return true; case R.id.entrieslist: //code here return true; case R.id.salesreport: //code here return true; case R.id.logout: //code here return true; default: return super.onOptionsItemSelected(item); } } }
Handling Action Bar Icon Click Events
Open your main activity and override onOptionsItemSelected() method. This method accepts menu item as a parameter. Selected action item can be identified by using it’s id.
user interface is displayed through an activity(Screen). Activity is used to represent the data to user and allows user interaction. In an android application, we can have multiple activities and they can interact with each other Interaction between multiple activities can be done only using Intent. Intents are objects of theandroid.content.Intent type. Your code can send them to the Android system defining the components you are targeting. In Android app development you face situations where you want to send or receive your data between one Activity (Screen) to another.
Intent i =newIntent(getApplicationContext(),NewActivity.class);
i.putExtra("key","value");
startActivity(i);
Then in the new Activity, retrieve those values:
Bundle extras = getIntent().getExtras();if(extras !=null){String value = extras.getString("key");//The key argument here must match that used in the other activity}
Use this technique to pass variables from one Activity to the other.
public class Genfunctions {
public void menuActions(String title,Context ct){
//this.context=context;
switch (title){
case "ENTRIES":
Intent intent = new Intent(ct, RptentrylistActivity.class);
ct.startActivity(intent);
break;
}
}//end of functions
}
Activity Class function call like this
Genfunctions gn = new Genfunctions();
gn.menuActions("ENTRIES",this);
The SQLite MAX function is an aggregate function that returns the maximum value of all values in a group.
public int getMaxid(){ String selectQuery = "SELECT max(id) as id FROM customerentries"; SQLiteDatabase database = this.getWritableDatabase(); Cursor cursor = database.rawQuery(selectQuery, null); cursor.moveToFirst(); int maxid = cursor.getInt(cursor.getColumnIndex("id")); return maxid; }
Solution for -
How to find the maximum value of the column in sqlite database
How to hide a particular column in Android TableRow
Try to Use setVisibility(View.GONE);
t3v.setVisibility(View.GONE);
TextView id = new TextView(EntriesActivity.this);
id.setText(content.get("id").toString());
id.setTextColor(Color.WHITE);
id.setVisibility(View.GONE);
row.addView(id);
Get total RowCount for TableLayout in Android
Through this code you can get the total rowCount for TableLayout