FAQS


How o hide application icon and title bar in rumtime

Views: 3574  |   Date: 2013-11-02 05:03:54

package com.tech.ashu;

import java.util.List;

import pete.android.study.R;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.widget.AdapterView.OnItemClickListener;

public class AppInfoAdapter extends BaseAdapter {
private Context mContext;
private List mListAppInfo;
private PackageManager mPackManager;
ApplicationInfo entry;
TextView tvAppName;
public AppInfoAdapter(Context c, List list, PackageManager pm) {
mContext = c;
mListAppInfo = list;
mPackManager = pm;
}

@Override
public int getCount() {
return mListAppInfo.size();
}

@Override
public Object getItem(int position) {
return mListAppInfo.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
// get the selected entry
entry = mListAppInfo.get(position);

// reference to convertView
View v = convertView;

// inflate new layout if null
if(v == null) {
LayoutInflater inflater = LayoutInflater.from(mContext);
v = inflater.inflate(R.layout.layout_appinfo, null);
}

// load controls from layout resources
ImageView ivAppIcon = (ImageView)v.findViewById(R.id.ivIcon);
tvAppName = (TextView)v.findViewById(R.id.tvName);
Switch s= (Switch)v.findViewById(R.id.switchForActionBar);
//TextView tvPkgName = (TextView)v.findViewById(R.id.tvPack);

// set data to display
ivAppIcon.setImageDrawable(entry.loadIcon(mPackManager));
tvAppName.setText(entry.loadLabel(mPackManager));
final String appName = tvAppName.getText().toString();

if (s != null)
{
s.setOnCheckedChangeListener(new OnCheckedChangeListener() {

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
ComponentName componentToDisable = new ComponentName(
entry.packageName,
"entry.packageName.LauncherActivity");

mPackManager.setComponentEnabledSetting(componentToDisable, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

Toast.makeText(mContext, appName, Toast.LENGTH_SHORT).show();
//Toast.makeText(mContext, ""+entry.loadLabel(mPackManager), Toast.LENGTH_SHORT).show();
}
});
}
else
{
Log.i("tag", "switch1 is null");
}

//tvPkgName.setText(entry.packageName);

// return view
return v;
}




}

Answer 1

Simply put the following line straight after the onCreate() method:
requestWindowFeature(Window.FEATURE_NO_TITLE);
e.g.

  @Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.main); 

 
Submit Your Answer
  |  
 
 
 

Preview :